Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento 2 custom module admin grid item duplicate

I try to create custom admin grid. When I search for information It can be searched But after I cancel the search The result is a duplicate of every item.

enter image description here

enter image description here

enter image description here

like image 493
FuFu Avatar asked Feb 10 '26 21:02

FuFu


1 Answers

You can fix this issue it by adding the storageConfig and the indexField item under the settings tag.

It will be something like this (Comments on the code will give you more information):

    <dataSource name="push_notification_pushNotificationLog_listing_data_source">
        <argument name="dataProvider" xsi:type="configurableObject">
            <!-- ... -->
            <argument name="primaryFieldName" xsi:type="string">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"/>
                    <!-- Add below tag -->
                    <item name="storageConfig" xsi:type="array">
                        <!-- Set it to your table primary key -->
                        <item name="indexField" xsi:type="string">id</item>
                    </item>
                </item>
            </argument>
        </argument>
    <!-- ... -->
    </dataSource>
like image 160
AmooAti Avatar answered Feb 15 '26 13:02

AmooAti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!