加载中...

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


  1. 视图文件
    1. <?php
    2. $add_drop = CHtml::dropDownList('catlist','',CmpCat::model()->getCmpCat('移动到分类'),array('class'=>'s_ipt w_120 removedropcatbatch'));
    3. $remove_drop = CHtml::dropDownList('catlist','',CmpCat::model()->getCmpCat('添加到分类'),array('class'=>'s_ipt w_120 adddropcatbatch'));
    4. ?>
    5. <?php
    6. $this->widget('zii.widgets.CListView', array(
    7. 'dataProvider'=>$model->search(),
    8. 'itemView'=>'_view',
    9. 'emptyText'=>'暂时没有数据',
    10. 'selectAll'=>array('ids[]','id[]'),
    11. 'pagerTemplate'=>'onlyPager',//底部不显示操作按钮
    12. 'pagerClass'=>'list_page f_r',//底部分类样式
    13. 'itemsTagName'=>'table',
    14. 'itemsOptions'=>array('class'=>'list_table list_table2','width'=>'100%','cellpadding'=>0,'cellspacing'=>0),
    15. 'artLink'=>array(
    16. //设为头条
    17. array(Yii::t('adm','Focus Set'),'/manage/news/refocus','确认将选中项目设为头条!'),
    18. //取消头条
    19. array(Yii::t('adm','Focus UnSet'),'/manage/news/unfocus','确认将选中项目取消头条!'),
    20. //信息推荐
    21. array(Yii::t('adm','Commend News'),'/manage/news/recommend','确认将选中项目推荐到信息首页!'),
    22. //取消推荐
    23. array(Yii::t('adm','Del Recommend'),'/manage/news/uncommend','确认选中项目取消推荐!'),
    24. //批量删除
    25. array(Yii::t('adm','Delete All'),'/manage/news/delete','确认批量删除选中项目!'),
    26. ),
    27. 'batchItem'=>array(
    28. //移动到分类
    29. $add_drop,
    30. //添加到分类
    31. $remove_drop,
    32. ),
    33. ));
    34. ?>
  2. jq代码
    1. <script type="text/javascript">
    2. //添加到分类
    3. $('.adddropcatbatch').bind('change',function(){
    4. var pid = $(".chkitem:checked").serialize() ;
    5. var catid = $(this).val();
    6. location.href='/company/cmpcat/addcmpcat?catid='+catid+'&'+pid;
    7. })
    8.  
    9. //移动到分类
    10. $('.removedropcatbatch').bind('change',function(){
    11. var pid = $(".chkitem:checked").serialize() ;
    12. var catid = $(this).val();
    13. location.href='/company/cmpcat/removecmpcat?catid='+catid+'&'+pid;
    14. })
    15. </script>

  3. 全选反选
    1. <?php echo CHtml::checkBox('id[]','',array('class'=>'chk f_l chkitem','onclick'=>'CheckList("ids[]","id[]")','value'=>$data->zp_id))?>
  4. 删除链接,确认弹框
    1. <?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.

    2.

还没有评论.