我需要用一个按钮创建一个 CGridView 并使按钮调用 javascript 函数,如下所示:
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'projectCities',
'summaryText' => '',
'dataProvider' => $model->getCitiesProvider(),
'columns' => array(
'name',
'directional',
'customCount',
array(
'class'=>'CButtonColumn',
'template'=>'{delete}',
'buttons' => array(
'delete' => array(
'url' => '',
'click' => '',
'options' => array(
'onclick' => 'removeCity(this, $data->idCity,
$model->idProject); return false;',
),
)
),
)
),
));
当然它不起作用,因为生成的html是:
<a class="delete" title="Delete" onclick="removeCity(this, $data->idCity, $model->idProject); return false;">
有没有办法做到这一点,以便在 javascript 函数调用中有正确的 id?