Question

You guys would be knowing that usually, we are using core Magento DataProvider while creating admin grid using UI component.

Sometimes, we need to add some filter or modify the basic grid collection data which brings all records stored in the respective table by default. For this, we need to create custom DataProvider to return our modified collection.

Can someone please provide some details or good reference regarding how can we make such DataProvider in the custom module for admin grid page?

That would be really helpful.

Thanks,

Was it helpful?

Solution

Finally, I have found the solution for this. It's really good which I didn't believe that it can be such easier.

Here, is the solution which you need to put in your ui component grid listing xml file:

Inside the <dataSource> tag :

<argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
          <item name="filter_url_params" xsi:type="array">
                <item name="product_id" xsi:type="string">*</item>
          </item>
    </item>
</argument>

Here, you need to add respective field name 'product_id' and put it's value as '*' by default. This will take product_id param value dynamically which you pass from the url.

That's it!

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