您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Yii中CGridView实现批量删除的方法

2024/4/16 0:36:53发布13次查看
本文实例讲述了yii中cgridview实现批量删除的方法。分享给大家供大家参考,具体如下:
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教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product