Rate this post

 

To Use Action of a Grid Backend Magento 2 with Custom Code, you need to follow these steps:

  1. Step 1: Create a grid Magento 2
  2. Step 2: Set Id for this grid
  3. Step 3: Create a template file with url
  4. Step 4: Get grid object name of the grid
  5. Step 5: Create a javascript object
  6. Step 6: Use some function

You may know How to Code Inline Editing Grid in Magento 2 Backend in the previous post. In this post, we will find How to Use Action of a Grid Backend Magento 2 with Custom Code . In Magento 1, it is so easy to create a grid show data in backend and Magento 2 is so similar. Only with some part , you may create a grid to show data from a table easily. However, Magento 2 gives you two ways to create a grid in backend. Today I will help you Use Action of a Grid Backend Magento 2 with Custom Code with simple way .

If you want to use some action of grid Magento 2 backend, you can follow this guide to do it.

Use Action of a Grid Backend Magento 2 with Custom Code

Step 1 : 

I created a grid Magento 2 like this.

app\code\My_Vendor\My_Module_Name\Block\Adminhtml\Product\Grid

Step 2:

In this grid, I set Id for this grid in _construct function.

Step 3:

I create a template file with url

app\code\My_Vendor\My_Module_Name\view\adminhtml\templates\product\grid.phtml

Step 4:

In this template I get grid object name of the grid

Step 5:

I create a javascript object from $gridJsObjectName

Step 6:

With this javascript object, you can use some function like  filter, reset filter, etc

The 6 steps I mention above is the shortest process for you to Use Action of a Grid Backend Magento 2 with Custom Code.  Hope all you guys can learn Magento 2 easier with our series lesson. With this guide, you can manage the Grid Backend Magento 2 easily. Every store has a Grid Backend Magento 2 with many attributes.

Thank you for reading this post. Good luck!

How to Add a Custom Template into UI Component Fieldset in Magento 2
How to Create a Frontend View in Magento 2