Yii Framework Forum: [Help] Error Approve All Cgridview Data With Checkbox - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Help] Error Approve All Cgridview Data With Checkbox Rate Topic: -----

#1 User is offline   ucinkmehonk 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-November 12

Posted 30 November 2012 - 08:41 PM

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"):("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
0

#2 User is offline   ankitv 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-March 13

Posted 08 April 2013 - 01:00 AM

This code works fine for me.Approved should be the attribute for your model.Check your Model Attributes.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users