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

4
  • Please provide more information. Did you use UI Component? Commented Dec 21, 2017 at 13:21
  • Please check below URL magento.stackexchange.com/questions/95371/…
    – Nits
    Commented Dec 21, 2017 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
    Commented Dec 21, 2017 at 13:31
  • @lisa You can take a reference from following answer Commented Dec 26, 2017 at 4:33

1 Answer 1

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>
3
  • 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
    Commented Jan 2, 2019 at 17:39
  • @Knight017, were you able to find how can we apply filter logic
    – surbhi agr
    Commented Jul 29, 2020 at 6:16
  • @surbhiagr not remeber exactly, but we have to find out the file which is used for collection filter from core,may be in di.xml where they specify the class , then need to rewrite it or we update it in di.xml and add the logic there.
    – Knight017
    Commented Aug 8, 2020 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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