3

enter image description hereI have a grid and I want to apply a custom filter on it, is there a way do that ? Thank you

  • Please provide more information. Did you use UI Component? – Salma Saiyad Dec 21 '17 at 13:21
  • Please check below URL magento.stackexchange.com/questions/95371/… – Nits Dec 21 '17 at 13:24
  • @SalmaSaiyad yes, i used ui component I have the filters of the default columns I want to add a custom filter, I added a photo that indicates the filter location to the question – lisa Dec 21 '17 at 13:31
  • @lisa You can take a reference from following answer – Salma Saiyad Dec 26 '17 at 4:33
2

You can take the reference for Status filter added in following XML to add custom filters. More information you can find here. http://devdocs.magento.com/guides/v2.2/ui_comp_guide/components/ui-filters.html

<listingToolbar name="listing_top">
        <bookmark name="bookmarks"/>
        <columnsControls name="columns_controls"/>
        <filters name="listing_filters">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="params" xsi:type="array">
                        <item name="filters_modifier" xsi:type="array"/>
                    </item>
                    <item name="observers" xsi:type="array">
                        <item name="filters" xsi:type="object">Magento\Catalog\Ui\Component\Listing\Filters</item>
                    </item>
                </item>
            </argument>
            <settings>
                <statefull>
                    <property name="applied" xsi:type="boolean">false</property>
                </statefull>
            </settings>
        <filterSelect name="status" provider="${ $.parentName }">
            <settings>
                <options class="Magento\Catalog\Model\Product\Attribute\Source\Status"/>
                <caption translate="true">Select...</caption>
                <label translate="true">Status</label>
                <dataScope>status</dataScope>
                <imports>
                    <link name="visible">componentType = column, index = ${ $.index }:visible</link>
                </imports>
            </settings>
        </filterSelect>
        </filters>
        <paging name="listing_paging"/>
    </listingToolbar>
  • Do you know how can we apply filter logic to query? I mean in which file we can add if you find custom filter (here status) then apply the filter logic. – Knight017 Jan 2 at 17:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.