3

I'm doing "search by fulltext" in "Banner Slider" module, and every thing works perfect, but when i click on "x" button to reset the search, it return exactly the same slide as the last slide which in the result. For example, i have 2 slide, "banner_1" and "banner_2" and after i search for "banner_1" (ofcause it work), and then i click on "x" button, and it return 2 "banner_1" (watch the image below):
enter image description here

EDIT 1:

Here is my xml file.

C:\xampp\htdocs\magento\app\code\Aht\BannerSlider\view\adminhtml\ui_component\banner_listing.xml

<dataSource name="banner_listing_data_source" component="Magento_Ui/js/grid/provider">
    <settings>
        <updateUrl path="mui/index/render"/>
    </settings>
    <aclResource>Aht_BannerSlider::banners</aclResource>
    <dataProvider class="Aht\BannerSlider\Ui\Component\DataProvider" name="banner_listing_data_source">
        <settings>
            <requestFieldName>id</requestFieldName>
            <primaryFieldName>id</primaryFieldName>
        </settings>
    </dataProvider>
</dataSource>

1 Answer 1

4

After ajax request it is showing the same. Same problem occur to me and here what i do to solve problem. Added below code

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

in you dataSource node.

<dataSource name="test_listing_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <argument name="class" xsi:type="string">testGridDataProvider</argument>
        <argument name="name" xsi:type="string">test_listing_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">test_id</argument>
        <argument name="requestFieldName" xsi:type="string">test_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">test_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>

This will solve your problem.

Update code for 2.2.5

       <settings>
            <storageConfig>
               <param name="indexField" xsi:type="string">test_id</param>
            </storageConfig>
            <updateUrl path="mui/index/render"/>
        </settings>
5
  • Thanks for replying. I've updated my post, please check. :)
    – fudu
    Aug 9, 2018 at 10:11
  • @fudu update the code kindly check and feedback
    – PROGOSTECH
    Aug 9, 2018 at 12:31
  • hold up, i'm gonna check it later ok ? :) Thanks you very much
    – fudu
    Aug 9, 2018 at 12:45
  • Its work perfectly, thanks you very much. But can you explain what the <storageConfig> does please?
    – fudu
    Aug 10, 2018 at 1:24
  • @fudu i did not find any definition of this but it used to store data in this you defined the column you want to store. in particular example it is setting index for storing data. you can read more on alanstorm.com/magento-2-ui-component-data-sources
    – PROGOSTECH
    Aug 10, 2018 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.