This seems like it should be obvious, but I haven’t been able to figure it out or find anything in the forum or cookbook about it.
I have a CGridView listing items retrieved that have a specific state (in the database); that part is working fine. I also have a button in CButtonColumn making an ajax request that changes that buttons state. The end result is that the row’s state is changed, and it should not appear in that list anymore (much like the CButtonColumn delete action).
How do I get the CGridView to refresh after making this request? I don’t want to reload the page each time, but haven’t been able to figure out how to use a renderPartial() in the controller to refresh the grid; I also looked over the CButtonColumn’s delete action, but couldn’t figure out how to implement that.
I don’t even think my CButtonColumn link is ajaxified right now, and I haven’t been able to figure out how to implement that in CButtonColumn - I’d assume it has something to do with the ‘click’ function, but don’t know how to do that with the newer versions of Yii; would anybody be able to give me a snippet illustrating how to implement that?
Here’s the CGridView column’s code:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'needApproval-grid',
'dataProvider'=>$dataProvider,
'ajaxUpdate'=>true,
'columns'=>array(
'project_name',
array(
'class'=>'CButtonColumn',
'template'=>'{view} {approve}',
'buttons'=>array(
'approve'=>array(
'label'=>'Approve for Review >>',
'url'=>'Yii::app()->controller->createUrl("project/makeReviewable",array("id"=>$data->project_oid))',
'options'=>array('class'=>'cssGridButton'),
),
),
),
),
));
… and here’s my controller action:
public function actionMakeReviewable() {
if(Yii::app()->request->isAjaxRequest) {
$model = $this->loadModel();
$model->status='2';
if($model->save() && Generic::newState($model->project_oid,$model->status)) {
$this->redirect(array('/workflow/needApproval'));
}
}
}