I have a custom admin grid for return items. For which I need to add a popup to add a comment for every action below

admin grid action

I have written a js function for the modal popup. But I am unable to trigger onclick event for action links. I have tried below code in UI action file, it is not working.

enter image description here

Many thanks in advance.

2 Answers 2

    ], function () {
        'use strict';

        return function (config) {

         * function
         * @param {String} event

        function customClickChange(event)
            console.log('i m click');
            // do whatever you want here


         * Initialize custom row
         * @param {Object} grid
         * @param {String} row
        function customRowInit(grid, row)
            var customAction = $(row).getElementsByClassName('classNameofYourAction')[0];

            if (customAction ) {

                Event.observe(checkbox, 'click', customClickChange);


        gridJsObject.initRowCallback = categoryProductRowInit;

        if (gridJsObject.rows) {
            gridJsObject.rows.each(function (row) {
                customRowInit(gridJsObject, row);

You can get class name of your edit action by inspect element. Hope it will work.


In first step we need to create block file :-


namespace Yournamespace\Modulename\Block\Adminhtml\Product;

class CustomActionList extends \Magento\Backend\Block\Widget\Container

     * @param \Magento\Backend\Block\Widget\Context $context
     * @param array $data
    public function __construct(
        \Magento\Backend\Block\Widget\Context $context,
        array $data = []
    ) {
        parent::__construct($context, $data);

    protected function _prepareLayout()
        $addButtonProps = [
            'id' => 'custom_action_list',
            'label' => __('Custom Action List'),
            'class' => 'add',
            'button_class' => '',
            'class_name' => 'Magento\Backend\Block\Widget\Button\SplitButton',
            'options' => $this->_getCustomActionListOptions(),
        $this->buttonList->add('add_new', $addButtonProps);

        return parent::_prepareLayout();

     * Retrieve options for 'CustomActionList' split button
     * @return array
    protected function _getCustomActionListOptions()
        /*list of button which you want to add*/
        'action_1'=>['label'=>__('Action 1'),'onclick'=>'setLocation("ACTION CONTROLLER")'],
        'action_2'=>['label'=>__('Action 2'),'onclick'=>'setLocation("ACTION CONTROLLER")'],
        'action_3'=>['label'=>__('Action 3'),'onclick'=>'setLocation("ACTION CONTROLLER")']
        /* in above list you can also pass others attribute of buttons*/
        return $splitButtonOptions;

Now we call this block file in layout page where we want to add this split button :-

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <!-- here we call our split button block   -->
            <block class="Yournamespace\Modulename\Block\Adminhtml\Product\CustomActionList" name="admin.product.customsplitbutton"/>
  • Hi, thanks for your answer. I have tried your code. It gave the button with dropdown at the top of the grid. But I want separate action links for every row.
    – sushanth
    Mar 23, 2019 at 7:11
  • you can define action in block 'onclick'=>'setLocation("yor action")' Mar 23, 2019 at 7:12
  • i have aleady written action controller for above links. But my requirement is to add comment for every action. For that iam trying to add popup
    – sushanth
    Mar 23, 2019 at 7:18
  • add comment for every action means ? Mar 23, 2019 at 14:49
  • If for example, admin wants to reject the return request, then he needs to mention the reason for rejection. So, I want popup input field to write this reason.
    – sushanth
    Mar 24, 2019 at 7:13

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.