Yii-视图- CListView操作扩展用法(zyd)

  1. 视图文件
    <?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'=>'_view',    
        'emptyText'=>'暂时没有数据',  
        'selectAll'=>array('ids[]','id[]'),  
        'pagerTemplate'=>'onlyPager',//底部不显示操作按钮
        'pagerClass'=>'list_page f_r',//底部分类样式
        'itemsTagName'=>'table',
        'itemsOptions'=>array('class'=>'list_table list_table2','width'=>'100%','cellpadding'=>0,'cellspacing'=>0),
        'artLink'=>array(  
            //设为头条 
            array(Yii::t('adm','Focus Set'),'/manage/news/refocus','确认将选中项目设为头条!'),  
            //取消头条
            array(Yii::t('adm','Focus UnSet'),'/manage/news/unfocus','确认将选中项目取消头条!'),  
            //信息推荐
            array(Yii::t('adm','Commend News'),'/manage/news/recommend','确认将选中项目推荐到信息首页!'),  
    		//取消推荐
    		array(Yii::t('adm','Del Recommend'),'/manage/news/uncommend','确认选中项目取消推荐!'),
    		//批量删除
    		array(Yii::t('adm','Delete All'),'/manage/news/delete','确认批量删除选中项目!'),
        ),  
        'batchItem'=>array(  
            //移动到分类  
            $add_drop,  
            //添加到分类  
            $remove_drop,  
        ),  
        ));  
    ?> 
  2. jq代码
    <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>

  3. 全选反选
    <?php echo CHtml::checkBox('id[]','',array('class'=>'chk f_l chkitem','onclick'=>'CheckList("ids[]","id[]")','value'=>$data->zp_id))?>
  4. 删除链接,确认弹框
    <?php echo CHtml::link(Yii::t('cmp','Delete'),'javascript:',array('class'=>'c_06c','onclick'=>'return art_del_confirm("/manage/expressCom/delete/id/'.$data->zec_id.'","你确定要删除这条信息吗?")'))?>

  5. 效果图
    1.Yii-视图- CListView操作扩展用法(zyd)_第1张图片

    2.Yii-视图- CListView操作扩展用法(zyd)_第2张图片

你可能感兴趣的:(视图,yii,clistview,操作扩展,CListView操作扩展)