hi,
i have some problems with submitButton for Approve data
this my code
View :
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'mahasiswa-form',
'enableAjaxValidation'=>true,
)); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'mahasiswa-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'id'=>'autoId',
'class'=>'CCheckBoxColumn',
'selectableRows' => '2',
),
'id',
'name',
'email',
array(
'name'=>'approved',
'filter'=>array('1'=>'Yes','0'=>'No'),
'value'=>'($data->approved=="1")?("Yes")<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />"No")'
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
<script>
function reloadGrid(data) {
$.fn.yiiGridView.update('mahasiswa-grid');
}
</script>
<?php echo CHtml::ajaxSubmitButton('Filter',array('mahasiswa/AjaxAPP'), array(),array("style"=>"display:none;")); ?>
<?php echo CHtml::ajaxSubmitButton('Approved',array('mahasiswa/AjaxAPP','act'=>'doApproved'), array('success'=>'reloadGrid')); ?>
<?php echo CHtml::ajaxSubmitButton('UnApproved',array('mahasiswa/AjaxAPP','act'=>'doUnapproved'), array('success'=>'reloadGrid')); ?>
<?php $this->endWidget(); ?>
Controller :
public function actionAjaxAPP()
{
$act = $_GET['act'];
$autoIdAll = $_POST['autoId'];
if(count($autoIdAll)>0)
{
foreach($autoIdAll as $autoId)
{
$model=$this->loadModel($autoId);
if($act=='doApproved')
$model->approved = 1;
if($act=='doUnapproved')
$model->approved = 0;
if($model->save())
echo 'ok';
else
throw new Exception("Sorry",500);
}
}
}
i use code from this post
but when i click ‘Approved’ or ‘UnApproved’ button nothing happen
‘approved’ data still have same value, even i use SubmitButton it still same, ‘approved’ data value not change at all,
can anyone solve this problems, thanks