1. cgridview中的columns添加
array( 'selectablerows' => 2, 'footer' => '批量删除', 'class' => 'ccheckboxcolumn', 'headerhtmloptions' => array('width'=>'33px'), 'checkboxhtmloptions' => array('name' => 'selectdel[]'),),
作用是添加多选框
2.js代码
3.action
public function actiondelall(){ if (yii::app()->request->ispostrequest) { $criteria= new cdbcriteria; $criteria->addincondition('id', $_post['selectdel']); words::model()->deleteall($criteria);//words换成你的模型 if(isset(yii::app()->request->isajaxrequest)) { echo cjson::encode(array('success' => true)); } else { $this->redirect(isset($_post['returnurl']) ? $_post['returnurl'] : array('index')); } } else throw new chttpexception(400,'invalid request. please do not repeat this request again.');}
希望本文所述对大家基于yii框架的php程序设计有所帮助。
以上就介绍了yii中cgridview实现批量删除的方法,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
