🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Add Action Column in Admin Grid in Magento 2 – The Complete Method

By Sanjay JethvaUpdated on Jul 18, 2025 3 min read

Magento 2 store owners can easily manage the products, customers, orders, and other information through grids. The action column enables you to perform record-specific actions such as deleting or editing.

If you’re looking for a method on how to add action column in admin grid in Magento 2, then you need to fix Magento 2 reset button in grid column and go futher in this blog post written for you!

Action column in admin ui grid in Magento 2 example

Magento developers, working on modules, often create custom admin UI grids. These grids can be customized by editing the specific .xml files. Adding the action columns to the admin UI grid in Magento 2 can help the merchant easily manage the records.

In this solution post, find the complete method to add action column to admin UI grid in Magento 2.

Method to Add Action Column in Admin Grid in Magento 2

To add action column to admin UI grid in Magento 2, you can use the ActionColumn component in the .xml file of the respective grid.

Here’s how to do that:

  • Open the UI Component file of the grid, which is present at app/code/Vendor/Extension/view/adminhtml/ui_component/{your_grid_file}.xml
  • Add the following code inside the <column> tags:
<actionsColumn name="actions" class="Vendor\Extension\Ui\Component\Listing\Column\Actions">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="resizeEnabled" xsi:type="boolean">false</item>
            <item name="resizeDefaultWidth" xsi:type="string">107</item>
            <item name="indexField" xsi:type="string">id</item>
        </item>
    </argument>
</actionsColumn>
  • Now, create Action.php file at app\code\Vendor\Extension\Ui\Component\Listing\Column with the following code:
<?php

namespace Vendor\Extension\Ui\Component\Listing\Column;

use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\UrlInterface;

class Actions extends Column
{
    const EDIT_PATH = 'extension/folder/controller';

    protected $urlBuilder;

    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        UrlInterface $urlBuilder,
        array $components = [],
        array $data = []
    ) {
        $this->urlBuilder = $urlBuilder;
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }

    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as & $item) {
                $name = $this->getData('name');
                if (isset($item['id'])) {
                    $item[$name]['edit'] = [
                        'href' => $this->urlBuilder->getUrl(self::EDIT_PATH, ['id' => $item['id']]),
                        'label' => __('Edit')
                    ];
                }
            }
        }

        return $dataSource;
    }
}

In the above codes, remember to replace Vendor and Extension accordingly.

The first section of the code defines and configures the Action column in the respective UI grid.  The second .php file defines the behavior of the column. In the above example, the prepareDataSource function generates individual links to edit each of the records.

That’s it! I hope the above steps will help you learn how to add action column in admin grid in Magento 2. Likewise you can also add image thumbnail column in Magento 2 admin UI grid. To add Inline Edit in UI Grid in Magento 2 Backend you can refer to our blog.

Did this solution help you? Share it with your developer friends via social media and spread the knowledge.

Thank You!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.