Hello, I’m new in Yii.
I have a problem with CButtonColumn inside CGridView,
what I want to achieve is generating dynamic onClick handler when a button in CButtonColumn is clicked.
Here’s what I’e tried and fail:
this->widget('zii.widgets.grid.CGridView', array(
'id'=>'roomTypeForm-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
//name button
'name',
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
'buttons' => array(
'update' => array(
'url' => '"#"',
'click' => '
function(){
openForUpdate($data->id,$data->name,function(){ alert("updated"); $.fn.yiiGridView.update("roomTypeForm-grid"); }); // << THIS IS WHAT I WANT
}
',
),
),
),
),
));
the problem is, this line:
'click' => '
function(){
openForUpdate($data->id,$data->name,function(){ alert("updated"); $.fn.yiiGridView.update("roomTypeForm-grid"); }); // << THIS IS WHAT I WANT
}
',
basically, the $data->id can’t be passed into the click event…
Is there any work around this?