I want to apply default filters on records while using magento 2 admin grid using UI Component.
I know there is a way while using block to render admin grid but i want the way using UI component.
I want to apply default filters on records while using magento 2 admin grid using UI Component.
I know there is a way while using block to render admin grid but i want the way using UI component.
Inject the below configs to your listing component, e.g., your_ui_component.xml
<listing ...>
<listingToolbar ...>
<filters ...>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="applied" xsi:type="array">
<item name="is_approved" xsi:type="string">1</item>
</item>
</item>
</argument>
</filters>
</listingToolbar>
</listing>
Source/credits: https://magento.stackexchange.com/a/178663/39320
You can add this in your ui_component/custom_listing.xml which should create filter button in grid:
<listingToolbar name="listing_top">
<filters name="listing_filters"/>
</listingToolbar>
And columns which should have been filtered needed to have "filter" field in column config, for ex.:
<column name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">Entity ID</item>
</item>
</argument>
</column>
© 2022 - 2024 — McMap. All rights reserved.