[英]How can I use Magento to create onclick set param grid
Currently I have this php
code: 目前,我有以下
php
代码:
$this->addColumn('action_urls', array(
'header' => $this->__('Update LP'),
//'index' => 'action_url',
'width' => '100',
'filter' => false,
'sortable' => false,
'type' => 'action',
'actions' => array(
array(
'caption' => Mage::helper('viajemos_general')->__('Update LP'),
'field' => 'action_url',
'onclick' => "showLandingPage('".$this->getUrl('admingeneral/adminhtml_LandingPagesUploader/createUpdateHotelProductLP/', array('id_viajemos' => $this->getId() ))."')"
)
),
)
);
I need to send in the row id in the 'onclick' from the grid, but with "$this->getId()" isn't possible. 我需要在网格中的“ onclick”中发送行ID,但无法使用“ $ this-> getId()”。
You cannot pass the id in onclick as in your example...you can only have it replaced in the url key as in this answer . 您不能像在示例中那样在onclick中传递ID ...您只能像在此答案中那样在url键中替换它。
However for you there is a solution: Give up of column of type 'action' and create a custom renderer...you can find a plenty of examples on net... here is one of them. 但是,对您而言,有一个解决方案:放弃“ action”类型的列并创建一个自定义渲染器...您可以在网上找到很多示例... 这里是其中一个。 Your custom render should look something like
您的自定义渲染应类似于
public function render(Varien_Object $row)
{
return '<span onclick="showLandingPage(\'' . $this->getUrl('admingeneral/adminhtml_LandingPagesUploader/createUpdateHotelProductLP/', array('id_viajemos' => $row->getId())) . '\')">' . $this->__('Update LP') . '</span>';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.