視圖文件 [html] <?php $add_drop = CHtml::dropDownList('catlist','',CmpCat::model()->getCmpCat('移動到分類'),array('class'=>'s_ipt w_120 removedropcatbatch')); $remove_drop = CHtml::dropDownList('catlist','',CmpCat::model()->getCmpCat('添加到分類'),array('class'=>'s_ipt w_120 adddropcatbatch')) ?> <?php $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$model->search(), 'itemView'=>'product_saleing_view', 'emptyText'=>'暫時沒有數據', 'selectAll'=>array('ids[]','id[]'), 'artLink'=>array( //首頁推薦 array(Yii::t('cmp','Recommended home'),'/company/product/recommend','確認推薦選中產品到首頁!'), //取消推薦 array(Yii::t('cmp','un Recommended home'),'/company/product/uncommend','確認取消推薦選中產品!'), //下架 array(Yii::t('cmp','downshelf'),'/company/product/downshelf','確認上架選中產品!'), ), 'batchItem'=>array( //移動到分類 $add_drop, //添加到分類 $remove_drop, ), )); ?> jq代碼 [html] <script type="text/javascript"> //添加到分類 $('.adddropcatbatch').bind('change',function(){ var pid = $(".chkitem:checked").serialize() ; var catid = $(this).val(); location.href='/company/cmpcat/addcmpcat?catid='+catid+'&'+pid; }) //移動到分類 $('.removedropcatbatch').bind('change',function(){ var pid = $(".chkitem:checked").serialize() ; var catid = $(this).val(); location.href='/company/cmpcat/removecmpcat?catid='+catid+'&'+pid; }) </script> 全選反選 [html] <?php echo CHtml::checkBox('id[]','',array('class'=>'chk f_l chkitem','onclick'=>'CheckList("ids[]","id[]")','value'=>$data->zp_id))?> 效果圖 1. 2.