0

Is there a way to make some listing select in filter to depend on some other select? I have seen this done on frontend checkout but that's a form not a list.

The idea is to make two columns searchable by select values but second select values are filtered by first option's value.

I tried something like this (similar to checkout implementation) but it does not work.

<column name="customer_id">
    <argument name="data" xsi:type="array">
        <item name="options" xsi:type="object">Module\Module\Model\Config\Source\Customers</item>
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">select</item>
            <item name="label" xsi:type="string" translate="true">Customer</item>
            <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
            <item name="dataType" xsi:type="string">select</item>
            <item name="dataScope" xsi:type="string">customer</item>
            <item name="sortOrder" xsi:type="number">75</item>
            <item name="sortable" xsi:type="boolean">false</item>
        </item>
    </argument>
</column>

<column name="address_id">
    <argument name="data" xsi:type="array">
        <item name="options" xsi:type="object">Module\Module\Model\Config\Source\Address</item>
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">select</item>
            <item name="label" xsi:type="string" translate="true">Address</item>
            <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
            <item name="dataType" xsi:type="string">select</item>
            <item name="dataScope" xsi:type="string">address_id</item>
            <item name="sortOrder" xsi:type="number">75</item>
            <item name="sortable" xsi:type="boolean">false</item>
            <item name="filterBy" xsi:type="array">
                <item name="target" xsi:type="string">${ $.provider }:${ $.parentScope }.customer_id</item>
                <item name="field" xsi:type="string">customer_id</item>
            </item>
        </item>
    </argument>
</column>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.