{"id":2795,"date":"2024-12-31T20:26:43","date_gmt":"2024-12-31T20:26:43","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/how-to-add-action-column-in-admin-grid-in-magento-2-the-complete-method\/"},"modified":"2025-07-18T17:03:52","modified_gmt":"2025-07-18T11:33:52","slug":"how-to-add-action-column-in-admin-grid-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/how-to-add-action-column-in-admin-grid-in-magento-2\/","title":{"rendered":"How to Add Action Column in Admin Grid in Magento 2 \u2013 The Complete Method"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re looking for a method on&nbsp;how to add action column in admin grid in Magento 2, then you need to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-reset-button-in-grid-column-not-working\/\">fix Magento 2 reset button in grid column<\/a>&nbsp;and go futher in this blog post written for you!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2023\/05\/Example-of-action-column-in-admin-ui-grid-in-Magento-2.png\" alt=\"Action column in admin ui grid in Magento 2 example\" class=\"wp-image-32145\" style=\"width:136px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Magento developers, working on modules, often&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-admin-grid-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">create custom admin UI grids<\/a>. These grids can be customized by editing the specific&nbsp;<code>.xml<\/code>&nbsp;files. Adding the action columns to the admin UI grid in Magento 2 can help the merchant easily manage the records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this solution post, find the complete method to add action column to admin UI grid in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Add Action Column in Admin Grid in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To add action column to admin UI grid in Magento 2, you can use the&nbsp;<a href=\"https:\/\/developer.adobe.com\/commerce\/frontend-core\/ui-components\/components\/actions-column\/\" target=\"_blank\" rel=\"noreferrer noopener\">ActionColumn<\/a>&nbsp;component in the&nbsp;<code>.xml<\/code>&nbsp;file of the respective grid.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here\u2019s how to do that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the UI Component file of the grid, which is present at&nbsp;<em><strong>app\/code\/Vendor\/Extension\/view\/adminhtml\/ui_component\/{your_grid_file}.xml<\/strong><\/em><\/li>\n\n\n\n<li>Add the following code inside the &lt;column&gt; tags:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;actionsColumn name=\"actions\" class=\"Vendor\\Extension\\Ui\\Component\\Listing\\Column\\Actions\">\n    &lt;argument name=\"data\" xsi:type=\"array\">\n        &lt;item name=\"config\" xsi:type=\"array\">\n            &lt;item name=\"resizeEnabled\" xsi:type=\"boolean\">false&lt;\/item>\n            &lt;item name=\"resizeDefaultWidth\" xsi:type=\"string\">107&lt;\/item>\n            &lt;item name=\"indexField\" xsi:type=\"string\">id&lt;\/item>\n        &lt;\/item>\n    &lt;\/argument>\n&lt;\/actionsColumn><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now, create&nbsp;<strong>Action.php<\/strong>&nbsp;file at&nbsp;<em><strong>app\\code\\Vendor\\Extension\\Ui\\Component\\Listing\\Column<\/strong><\/em>&nbsp;with the following code:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace Vendor\\Extension\\Ui\\Component\\Listing\\Column;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface;\nuse Magento\\Framework\\View\\Element\\UiComponentFactory;\nuse Magento\\Ui\\Component\\Listing\\Columns\\Column;\nuse Magento\\Framework\\UrlInterface;\n\nclass Actions extends Column\n{\n    const EDIT_PATH = 'extension\/folder\/controller';\n\n    protected $urlBuilder;\n\n    public function __construct(\n        ContextInterface $context,\n        UiComponentFactory $uiComponentFactory,\n        UrlInterface $urlBuilder,\n        array $components = [],\n        array $data = []\n    ) {\n        $this->urlBuilder = $urlBuilder;\n        parent::__construct($context, $uiComponentFactory, $components, $data);\n    }\n\n    public function prepareDataSource(array $dataSource)\n    {\n        if (isset($dataSource['data']['items'])) {\n            foreach ($dataSource['data']['items'] as &amp; $item) {\n                $name = $this->getData('name');\n                if (isset($item['id'])) {\n                    $item[$name]['edit'] = [\n                        'href' => $this->urlBuilder->getUrl(self::EDIT_PATH, ['id' => $item['id']]),\n                        'label' => __('Edit')\n                    ];\n                }\n            }\n        }\n\n        return $dataSource;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above codes, remember to replace Vendor and Extension accordingly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first section of the code defines and configures the Action column in the respective UI grid.&nbsp; The second .php file defines the behavior of the column. In the above example, the&nbsp;<code>prepareDataSource<\/code>&nbsp;function generates individual links to edit each of the records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s 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\u00a0<a href=\"https:\/\/meetanshi.com\/blog\/add-image-thumbnail-column-in-magento-2-admin-ui-grid\/\">add image thumbnail column in Magento 2<\/a>\u00a0admin UI grid. To add <a href=\"https:\/\/meetanshi.com\/blog\/add-inline-edit-in-ui-grid-in-magento-2-backend\/\" data-type=\"link\" data-id=\"https:\/\/meetanshi.com\/blog\/add-inline-edit-in-ui-grid-in-magento-2-backend\/\">Inline Edit in UI Grid in Magento 2 Backend<\/a> you can refer to our blog.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Did this solution help you? Share it with your developer friends via social media and spread the knowledge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You!  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2795","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2795"}],"version-history":[{"count":7,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2795\/revisions"}],"predecessor-version":[{"id":18626,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2795\/revisions\/18626"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}