How to Use Grid Renderer in Magento 2

Magento 2 admin grids in the backend help the admin to manage the data of orders, customers, products, etc. He can edit, update or delete the data from the admin grid.

Additionally, the admin may use grid renderer in Magento 2 to change the default formatting of the columns such as highlighting, uploading images, change the text color or background, etc. A renderer is one of the methods of Magento 2 that holds a path of a PHP file and redirects to that file.

For instance, your Magento 2 store allows users to create profiles and upload their profile images. In the backend Customers grid, the admin can get the profile picture column using the below solution.

Also, the column entries can be diversified with colors such as a male customer with red and female customer with green color. It helps the admin visually understand the data diversification and get the ratio of their customers by gender.

Check the below solution to implement any such scenarios where you need to change the default formatting of the admin grid columns in Magento 2.

Method to Use Grid Renderer in Magento 2

  1. Use the below code in the registration.php file at app\code\Vendor\Module
  2. Create the module.xml file at app\code\Vendor\Module\etc

  3. Create the Grid.php file at app\code\Vendor\Module\Block\Adminhtml\CustomField\Edit\Tab

  4. Create Balance.php file at app\code\Vendor\Module\Block\Adminhtml\Customer\Grid\Renderer

The output of the above implementation will be:

How to Use Grid Renderer in Magento 2

That’s it to use grid renderer in Magento 2!

If you have any doubts regarding this post, just mention them in the Comments section below.

I would be happy to help.

Feel free to share the solution with Magento Community via social media.

Thank You.

 

5
(based on 6 Reviews)
How to Use Grid Renderer in Magento 2

Kanchi Upadhyay

Kanchi is a Magento Developer at Meetanshi. Apart from that, she is into dancing. In her free time, she likes to make handmade art and craft.

Leave a Reply

Your email address will not be published. Required fields are marked *