I created a grid in admin by XML UI components.
I need to filter collection via a URL parameter and I don't know how to achieve that. I tried to inject RequestInterface to the collection, but the filter didn't work.
di.xml
<virtualType name="SlideListingDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
<arguments>
<argument name="collection" xsi:type="object" shared="false">xxx\xxx\Model\ResourceModel\Grid\Slide\Collection</argument>
<argument name="filterPool" xsi:type="object" shared="false">SlideListingFilterPool</argument> <!-- Define new object for filters -->
</arguments>
</virtualType>
<virtualType name="SlideListingFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
<arguments>
<argument name="appliers" xsi:type="array">
<item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
<item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
</argument>
</arguments>
</virtualType>
<virtualType name="xxx\xxx\Model\ResourceModel\Grid\Slide\Collection" type="xxx\xxx\Ui\Component\DataProvider\SearchResult\Slide">
<arguments>
<argument name="mainTable" xsi:type="string">advox_sliders_slide</argument>
<argument name="resourceModel" xsi:type="string">xxx\xxx\Model\ResourceModel\Slide</argument>
</arguments>
</virtualType>
you have to write after update_url in ui components
`<item name="update_url" xsi:type="url" path="mui/index/render"/>`
after this line you have to add below code
<item name="filter_url_params" xsi:type="array">
<item name="status" xsi:type="boolean">1</item>
</item>
now you have to pass the status value in url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With