Posts Tagged ‘magento grid’

Hello guys,

We can add new action in grid row like ‘Edit’ link at admin grid.

Open your module Grid.php file, below is path to file:
(i.e. yourproject/app/code/local/yourcompany/yourmodulename/block/adminhtml/modulename/grid.php)

In That file, search ‘action’ column, it will be like below code:


$this->addColumn('action',
array(
          'header' => Mage::helper('modulename')->__('Action'),
          'width' => '100',
          'type' => 'action',
          'getter' => 'getId',
          'actions' => array(
                 array(
                      'caption' => Mage::helper('modulename')->__('View'),
                      'url' => array('base'=> '*/*/view'),
                      'field' => 'id'
                    )),
          'filter' => false,
          'sortable' => false,
          'index' => 'stores',
          'is_system' => true,
));

To add new action, you need to add another array in parameter ‘actions’ like below


array(
    'caption' => Mage::helper('modulename')->__('Edit'),
    'url' => array('base'=> '*/*/edit'),
    'field' => 'id'
)

So now code will be like below:



$this->addColumn('action', array(
                      'header' => Mage::helper('modulename')->__('Action'),
                      'width' => '100',
                      'type' => 'action',
                      'getter' => 'getId',
                      'actions' => array(
                              array(
                                 'caption' => Mage::helper('modulename')->__('View'),
                                 'url' => array('base'=> '*/*/view'),
                                 'field' => 'id'
                              ),
                              array(
                                  'caption' => Mage::helper('modulename')->__('Edit'),
                                  'url' => array('base'=> '*/*/edit'),
                                  'field' => 'id'
                              )
                      ),
                      'filter' => false,
                      'sortable' => false,
                      'index' => 'stores',
                      'is_system' => true,
                )
);

I hope the above information will help you.

Thanks,
Bijal Bhavsar 🙂

Advertisements