15

I created ui grid in magento 2.1.0 and facing issue while removing filters or clear all filters from ui grid. My filtered result occupies whole grid means same row repeated in the whole grid after removing filter.

I figure out why this issue arise, but unable to fix this issue.

Issue arise due to mui/index/render get request does not fire while removing filter or clear all filter.

In fact it worked when 2 or more filters are applied and I remove them but not in case of last filtered applied.

1
  • This is happening due to special caching for 1st active appilied filter.Please give me any suggestions to resolve this issue. Aug 13, 2016 at 5:28

4 Answers 4

30

Just to add to the previous solution by Tony Bartiloro. The specific fix is to add the 'storageConfig' item. If this is missing you will see the issue where row data is duplicated.

<item name="storageConfig" xsi:type="array">
    <item name="indexField" xsi:type="string">entity_id</item>
</item>

Where 'entity_id' is your primary key for the collection data, and also the same as defined in

<argument name="primaryFieldName" xsi:type="string">entity_id</argument>

And the following can be removed completely. As this is just duplicating the value specified already in the 'dataProvider' node.

<argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
        <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
    </item>
</argument>
2
  • yes you are right , its working now Aug 24, 2016 at 7:57
  • Cheers to your solution :) +1 from me
    – Keyur Shah
    Dec 12, 2016 at 11:56
18

i had same issue and I resolve with this code in ui_component xml:

<dataSource name="storelocator_store_listing_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <argument name="class" xsi:type="string">StoreGridDataProvider</argument>
        <argument name="name" xsi:type="string">storelocator_store_listing_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">store_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="storageConfig" xsi:type="array">
                    <item name="indexField" xsi:type="string">store_id</item>
                </item>
            </item>
        </argument>
    </argument>
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
        </item>
    </argument>
</dataSource>

Take a look at node name "DataProvider". Hope it helps

2
  • 2
    Yes , it worked great , Thanks a lot tony :) Aug 19, 2016 at 11:09
  • thanks @Tony u have saved my time working perfect so +vote Aug 4, 2017 at 9:50
12

I've got the same issue on Magento 2.3 and resolved by using the following code in ui_component.xml.

<dataSource component="Magento_Ui/js/grid/provider" name="listing_data_source">
        <settings>
            <storageConfig>
                <param name="indexField" xsi:type="string">primary_id</param>
            </storageConfig>
            <updateUrl path="mui/index/render"/>
        </settings>
        ...
        ...
</dataSource>
13
  • 1
    @Aasim Goriya, Me also got same issue, added your code. Now filters working fine. Thank you, you saved my time.
    – balu
    Jul 23, 2019 at 12:12
  • 1
    @DhadukMitesh what do you mean by default filter? can you please explain more? Dec 23, 2019 at 13:44
  • 1
    @DhadukMitesh ok so your issue is when you reset the filter your grid doesn't show all values correct? Dec 24, 2019 at 5:05
  • 1
    @DhadukMitesh I don't think this can be possible, as Magento's grid data save in ui_bookmark table and when you filter the data will save in ui_bookmark so it can't be possible to reset filter until data change in ui_bookmark table, so you need to remove ui_bookmark table entries while your page load. Dec 24, 2019 at 5:21
  • 1
    thanks more to you
    – Sourav
    Aug 7, 2020 at 11:45
0

In your ui_component listing.xml file, find

<dataSource component="Magento_Ui/js/grid/provider"

Add / Update it by below code

<dataSource component="Magento_Ui/js/grid/provider" name="......_listing_data_source">
    <settings>
        <storageConfig>
            <param name="indexField" xsi:type="string">primary_key_id_here</param>
        </storageConfig>
        <updateUrl path="mui/index/render"/>
    </settings>
    <aclResource>......</aclResource>
    <dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider" name="......_listing_data_source">
        <settings>
            <requestFieldName>id</requestFieldName>
            <primaryFieldName>primary_key_id_here</primaryFieldName>
        </settings>
    </dataProvider>
</dataSource>

In short, add <storageConfig> tag in <dataSource>

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.