2

私が欲しいのは、「新規追加」ボタンのアクションを変更することです

 class World_Exporter_Block_Adminhtml_Attribute extends    Mage_Adminhtml_Block_Widget_Grid_Container{
    public function __construct()
    {

            $location = str_replace('new', 'newMap', $this->getCreateUrl());

            $this->_controller = 'adminhtml_attribute';
            $this->_blockGroup = 'exporter';
            $this->_headerText = Mage::helper('exporter')->__('Attribute Manager ');
            $this->_addButtonLabel = Mage::helper('exporter')->__('Add Item');





            parent::__construct();

            $this->setCreateUrl($location);

                $this->_addButton('add', array(
                 'label'     => $this->getAddButtonLabel() ,
                'onclick'   => 'setLocation(\'' . $location .'\')',
                'class'     => 'add',
             ));

            // echo $this->getCreateUrl();
    }
}

いろいろ試した後でも、「newAction」を他のものに変更できます.. Plz help

4

2 に答える 2

7

Yevgenyの答えは良いですが、彼のコードでいくつかの小さなことを変更します:

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();

または、元のボタンがグリッドに残ります。

于 2013-05-13T17:02:13.797 に答える
1
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'
    ));

}
于 2013-05-08T09:53:48.923 に答える