Yii Framework Forum: Mass action YII checkbox cgridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Mass action YII checkbox cgridview ALL actions

#1 User is offline   begin_yii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 24-July 13

Posted 19 May 2015 - 05:14 AM

Any one Please help me!!!
In the link

http://www.yiiframew...kbox-cgridview/

bulk delete action shown, I need the same functionality for bulk update,
Like .. After selecting the rows using check boxes and click the button updateAll the screen to be shown with some fields with a save button, after filling the fields then save clicked the selected records should be updated Please help me !!!

<?php
public function actionUpdateall()
{
if (isset($_POST['mymodel-grid_c0']))
{
$upd_mod = $_POST['mymodel-grid_c0'];

$uname=Yii::app()->user->name;
$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();

$cs->registerScriptFile($baseUrl.'/js/utility.js');
$cs->registerScriptFile($baseUrl.'/js/validations.js');

$model = new Mymodel;
$cnt=count($_POST);
$isinw = isset($_POST['mymodel']);
//if(isset($_POST['mymodel']))
Dialog::message('title',"count is $cnt and $isinw");
if($cnt<1)
{
$model->attributes=$_POST['Mymodel'];

if($uname<>'recorduser' and
($model->fno!='' or $model->fno!=null) or
($model->year!='' or $model->year!=null))
$model->scenario='PR';

if(($uname==='recorduser') and $model->clo_yn==='Y')
$model->scenario='finalization';

if($model->validate()){
foreach ($upd_mod as $pk){
$umodel = Mymodel::model()->findByPk($pk);

if($umodel->updateallFields($model)){
$umodel->save();
}
}
//$this->actionAdmin();
$this->render('admin',array(
'model'=>$model,
));
}else{

Dialog::message('ERROR', "unable to save $cnt");
}


}else{

$this->render('updateall',array(
'model'=>$model,
));
}
}
else
{
//Yii::app()->user->setFlash('error', 'Please select at least one record to Update.');
Dialog::message('ERROR', "Please select at least one record to Update.");
$model = new Mymodel;
$this->render('admin',array(
'model'=>$model,
));
}
}
?>

In the above one, how to render the view updateall and then save batch update the screen having the fno,yr and some other fields these fields to be batch updated.

Kindly help!!!

the isset($_POST['mymodel']) is not rendering the view..
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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