Add a custom action to grid
1. In your Grid.php action do the following
<?php ... $this->addColumn('action', array( 'header' => Mage::helper('promolink')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', 'actions' => array( array( 'caption' => Mage::helper('promolink')->__('Delete'), 'url' => array('base' => '*/*/delete'), 'field' => 'id' ) ), 'filter' => false, 'renderer' => 'Vendorname_Modulename_Block_Adminhtml_Template_Grid_Renderer_Youraction', 'sortable' => false, 'index' => 'id', 'is_system' => true, )); .. |
2. Create a file Vendorname/Modulename/Block/Adminhtml/Template/Grid/Renderer/Youraction.php
and add the following to it:
<?php class Vendorname_Modulename_Block_Adminhtml_Template_Grid_Renderer_Youraction extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action { public function render(Varien_Object $row) { $value = $row->getData('id'); if($value == $row->getData('id')) { return '<a href="'.$this->getUrl('adminhtml/promolink_index/delete',array('id'=>$row->getData('id'))).'">Delete</a>'; } else { return false; } } |