0

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,

2 Answers 2

1

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!

0

See this, hope it helps.

https://www.mage-world.com/blog/grid-and-form-in-magento-2-admin-panel-part-1.html

Thanks,

3
  • Hello @John. The reference link you provided is making grid using block and layout files not using UI Component. Commented Aug 31, 2018 at 12:36
  • check this one. webkul.com/blog/how-to-create-a-grid-using-ui-component
    – Akash
    Commented Aug 31, 2018 at 12:38
  • Hi, @John. I already checked the above link you posted. Actually, that link shows basic way to create admin grid using UI Component. It is using core magento Data Provider instead of the custom one. Commented Aug 31, 2018 at 13:00

Your Answer

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

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