ok at least done something by my own…so below is my code in View file - update. I would like to update the model by check the checkbox.
So below code is successfully get the NID but i do not know how to update the model. Any one can help ??
6794
<?php
?>
<div class="form">
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'social-box-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'nid'); ?>
<?php echo $form->textField($model,'nid',array('size'=>11,'maxlength'=>11)); ?>
<?php echo $form->error($model,'nid'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php
$this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'box-grid',
'dataProvider'=>$dataProvider,
'selectableRows'=>1,
'afterAjaxUpdate' => 'reInstallButtons',
'columns' => array(
array(
'header' => 'No.',
'value' => '++$row',
),
array(
'name' => 'NID',
'type' => 'raw',
'value' => 'CHtml::encode($data["nid"])'
),
array(
'name' => 'Title',
'type' => 'raw',
'value' => 'CHtml::encode($data["title"])',
),
array(
'header' => 'Show',
'class'=>'CCheckBoxColumn',
'id'=>'box_id',
'selectableRows' => null,
'checked'=>'0'
),
),
));
?>
<?php
$str_js = "
function reInstallButtons() {
installButtons();
}
function installButtons() {
$('input[type=checkbox]').click(function(){
var data = $. fn.yiiGridView.getChecked('box-grid', 'box_id');
var dataString = JSON.stringify(data);
console.log('Box 1 updated!!' + dataString);
});
}
installButtons();
";
Yii::app()->clientScript->registerScript('status-update', $str_js);
?>