“我可以换吗?”;创建url";在magento网格中,位于;添加新的“;按钮

“我可以换吗?”;创建url";在magento网格中,位于;添加新的“;按钮,magento,grid,Magento,Grid,我想要的是更改“添加新”按钮的操作 在尝试了这么多之后,我仍然能够将“newAction”更改为任何其他。。Plz helpYevgeny的回答很好,但我会修改他的代码中的一些小东西: public function __construct() { $this->_controller = 'adminhtml_collection'; $this->_blockGroup = 'story'; $this->_headerText = Mage::he

我想要的是更改“添加新”按钮的操作


在尝试了这么多之后,我仍然能够将“newAction”更改为任何其他。。Plz help

Yevgeny的回答很好,但我会修改他的代码中的一些小东西:

public function __construct()
{
    $this->_controller = 'adminhtml_collection';
    $this->_blockGroup = 'story';
    $this->_headerText = Mage::helper('customer')->__('Manager');
    parent::__construct();
    $this->_addButton('add', array(
        'label' => Mage::helper('story')->__('Add Item'),
        'onclick' => "setLocation('" . $this->getUrl('*/*/new', array('page_key' => 'collection')) . "')",
        'class' => 'add'
    ));

}
public function __construct()
{
    $this->_controller = 'adminhtml_collection';
    $this->_blockGroup = 'story';
    $this->_headerText = Mage::helper('customer')->__('Manager');

    //Replace the first argument "add" by something else,
    //or both your new button and the original add button
    //won't be visible.
    $this->_addButton('btnAdd', array(
        'label' => Mage::helper('story')->__('Add Item'),
        'onclick' => "setLocation('" . $this->getUrl('*/*/new', array('page_key' => 'collection')) . "')",
        'class' => 'add'
    ));

    //Moved parent's constructor here (not necessary I think)
    parent::__construct();

    //Remove original add button
    $this->_removeButton('add');
}
此行删除了原始的“添加”按钮,只留下包含新操作的新按钮:

$this->_removeButton('add');
注意:请确保在呼叫后删除原始按钮:

parent::__construct();

或者原始按钮将保留在网格中。

请描述一下您实际想要实现的目标。。。是否要更改所有adminhtml网格中的添加新操作?还是只针对特定网格?用功能性的方式描述它:这是magento标准中正在发生的事情,也是我想要发生的事情。我已经将“newAction”操作分配给了其中一个网格,我不希望任何其他按钮将我带到相同的“newAction”操作。我认为这是有道理的,“新行动”行动已经在使用。不是吗?如果您有更好的解决方案,就像我们可以添加另一个控制器或类似的东西一样,我将不胜感激。将$this->getUrl('*/*/new',array('page_key'=>'collection')更改为$this->getUrl('*/*/newMap'))
parent::__construct();