I’m trying to update Yii CGridView record in modal widow,I added a button in CButtoncolumn.
array(
'class'=>'CButtonColumn',
'htmlOptions' => array('style'=>'width:76px;'),
'header'=>'Actions',
'template'=>'{view}{updateboard}{delete}',
'buttons'=>array(
'updateboard'=>
array(
'label'=>'Update Board',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/update.png',
'click'=>"function(){
$.fn.yiiGridView.update('boards-grid', { //change my-grid to your grid's name
type:'POST',
url:$(this).attr('href'),
success:function(data) {
$.fn.yiiGridView.update('boards-grid'); //change my-grid to your grid's name
}
})
return false;
}
",
'url'=>'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))',
), //updateboard
) // buttons
),
but it is not opening a model window,is there a better solution to update my cgridview record in modal window.
This is my controller code
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Boards']))
{
$model->attributes=$_POST['Boards'];
if($model->save()){
return true;
}
}