2

I'm going to add the request param to filter the Grid Listing. The url will be like: abc/xyz/status/2 And the collection will filter which record that have "status" value equal 2. I want to found something to add to my listing.xml like:

<item name="add_filter" xsi:type="string">status</item>
</item>
2
  • Do you need to show this filters in "applied filters" block with possibility of clear filters?
    – Max
    Mar 10, 2018 at 11:34
  • @Max yes I do. Do you have any suggestion?
    – Nero Phung
    Mar 10, 2018 at 15:16

2 Answers 2

2

I have used below code in my module for similar requirement:

<dataSource name="listing_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        ...
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="update_url" xsi:type="url" path="mui/index/render"/>
                <item name="filter_url_params" xsi:type="array">
                    <item name="status" xsi:type="string">*</item>
                </item>
            </item>
        </argument>
    </argument>    
</dataSource>

Here in <item name="status" xsi:type="string">*</item> status is your url request part.

Let me know if need anymore clarification or help.

0

thats Christian from Germany. I followed your instructiuons to place a url filter in my grid. I have added my grid with "insertlisting" to an ui form fieldset and I tried to get a filter from the url. But nothing works. Can you tell me, what I am doing wrong??

    <dataSource name="mcas_ghscategory_ghscategory_listing_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
        <argument name="name" xsi:type="string">mcas_ghscategory_ghscategory_listing_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">ghscategory_id</argument>
        <argument name="requestFieldName" xsi:type="string">id</argument>
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
                <item name="update_url" xsi:type="url" path="mui/index/render"/>
            <item name="filter_url_params" xsi:type="array">
                <item name="ghsclass_id" xsi:type="string">*</item>
            </item>
                 <item name="storageConfig" xsi:type="array">
                    <item name="indexField" xsi:type="string">ghscategory_id</item>
                </item>
            </item>
        </argument>
    </argument>
</dataSource>

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.