Thursday, September 27, 2012

Magento : Add custome button and remove button in magento admin grid

Consider module 'Bd_Demo' and Model 'Test'
Edit Grid Container File Test.php
public function __construct()
{
        $this->_controller = 'adminhtml_test';
        $this->_blockGroup = 'test';
        $this->_headerText = Mage::helper('demo')->__('Test Manager');
        $this->_addButtonLabel = Mage::helper('demo')->__('Add Test');


        $this->_addButton('button1', array(
            'label'     => Mage::helper('demo')->__('Button Label1'),
        'onclick'   => "setLocation('".$this->getUrl('*/*/button1')."')",
           
        ));

    $this->_removeButton('add'); // remove Add test button

        parent::__construct();
}

Note : button1Action() method must be in admin controller

2 comments: