Magento Grid – Add Multiple URL Names and Field AddColumn Action

actionarraygridurl

I have this code:

$grid->addColumn('action',array(
            'header'    => $this->__('Action'),
            'type'      => 'action',
            'action'    => array(
                'label'     => $this->__('Join Program'),
                'url'       => 'urlstring/index/join',
                'name'      => 'id',
                'field'     => 'program_id'             
            )
        ));

I want to set multiple url parameters. So in other word I need to achieve something like this:

$grid->addColumn('action',array(
            'header'    => $this->__('Action'),
            'type'      => 'action',
            'action'    => array(
                'label'     => $this->__('Join Program'),
                'url'       => 'urlstring/index/join',
                'name'      => 'id',
                'field'     => 'program_id',
                'name'      => 'PARAMETER2',
                'field'     => 'PARAMETER2'             
            )
        ));

This does not work. What is the proper way to achieve this? How can I set PARAMETER2?

Best Answer

I found some examples from Magento core /app/code/core/Mage/Adminhtml/Block/Backup/Grid.php :

$this->addColumn('action', array(
            'header'    => Mage::helper('backup')->__('Action'),
            'type'      => 'action',
            'width'     => '80px',
            'filter'    => false,
            'sortable'  => false,
            'actions'   => array(array(
                'url'       => $this->getUrl('*/*/delete', array('time' => '$time', 'type' => '$type')),
                'caption'   => Mage::helper('adminhtml')->__('Delete'),
                'confirm'   => Mage::helper('adminhtml')->__('Are you sure you want to do this?')
            )),
            'index'     => 'type',
            'sortable'  => false
        ));

or from /app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php :

$this->addColumn('action',
            array(
                'header'    => Mage::helper('catalog')->__('Action'),
                'width'     => '50px',
                'type'      => 'action',
                'getter'     => 'getId',
                'actions'   => array(
                    array(
                        'caption' => Mage::helper('catalog')->__('Edit'),
                        'url'     => array(
                            'base'=>'*/*/edit',
                            'params'=>array('store'=>$this->getRequest()->getParam('store'))
                        ),
                        'field'   => 'id'
                    )
                ),
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
        ));

We see here an easiest way to send multiple parameters through url

Related Topic