repeated_rows
Category

The Magento admin grid shows the same data for all rows unless filter

Recently I faced an issue, with my Magento 2 admin custom grid that all the rows are repeating the same value that exists in one row, but if I apply any filter, then the actual data will get displayed. So after doing a lot of research and core code review I got to understand my small silly mistake and that is, I forgot to add storageConfig in the ui_component.

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

Let me write down the whole block for a better understanding

<dataSource name="namespace_module_grid_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">ModuleGridDataProvider</argument>
<argument name="name" xsi:type="string">namespace_module_grid_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">store_id</argument>
<argument name="requestFieldName" xsi:type="string">store_id</argument>
<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="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>

Happy Coding

Leave a Reply

Your email address will not be published. Required fields are marked *