目前我有这个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() ))."')"
)
),
)
);
我需要从网格的"onclick"中发送行 id,但使用"$this->getId()"是不可能的。
您不能像示例中那样在 onclick 中传递 id...您只能像本答案一样在 URL 键中替换它。
但是,对您来说有一个解决方案:放弃"action"类型的列并创建自定义渲染器...你可以在网上找到很多例子...这是其中之一。您的自定义渲染应如下所示
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>';
}