Question

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.

Was it helpful?

Solution

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>

OTHER TIPS

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

I have 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>

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>

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top