0

I want to remove the Add New button and edit functionality when row is clicked. I've followed this tutorial. I've got all the features as guided in the tutorial. But in my case this grid table must be viewable only. Instead of edit I would like to have a detail viewing page. The grid is as below: enter image description here

1

To remove the add button add this to Foo_Bar_Block_Adminhtml_Baz::__construct()

public function __construct()
{
    // The blockGroup must match the first half of how we call the block, and controller matches the second half
    // ie. foo_bar/adminhtml_baz
    $this->_blockGroup = 'myname_mygateway';
    $this->_controller = 'adminhtml_mycontroller';
    $this->_headerText = $this->__('My Orders');
    parent::__construct();
    $this->_removeButton('add');

}

To make grid row unclickable change Foo_Bar_Block_Adminhtml_Baz_Grid from

public function getRowUrl($row)
{
    // This is where our row data will link to
    return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}

to

public function getRowUrl($row)
{
    return false;
}

To link to your detailed view change the controller action ...

public function getRowUrl()
{
    return $this->getUrl('*/*/yourAction', array('id' => $row->getId()));
}
  • Hello @sv3n , return false from getRowUrl($row) does the trick of being unclickable and changing action changes the page accordingly. But $this->_removeButton('add'); is doing nothing. Could I be making mistake. This is my first time working with magento 1. So please help me in this. – Purushotam Sangroula Jan 23 '18 at 2:23
  • Add button got remove by placing above code in my constructo after parent constructor. Cheers mate. – Purushotam Sangroula Jan 23 '18 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.