码迷,mamicode.com
首页 > 其他好文 > 详细

YII框架CGridView分页实现

时间:2015-01-27 14:40:48      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

C控制器层

$model = new User(‘search‘);
        $model->unsetAttributes();
        $dataProvider = $model->search();
$this->render(‘company‘,array(
            ‘dataProvider‘=>$dataProvider,
            ‘model‘=>$model,
        ));

 解释:$model->unsetAttributes();将属性置空;

V视图层

$this->widget(‘zii.widgets.grid.CGridView‘, array(
        ‘itemsCssClass‘ => ‘table table-striped table-bordered table-hover‘,
        ‘pagerCssClass‘=>‘margin-top-20‘,
        ‘htmlOptions‘=>array(‘class‘=>‘portlet-body‘),
        ‘pager‘=>array(
            ‘class‘=>‘CLinkPager‘,
            ‘header‘=>‘‘,
            ‘htmlOptions‘=>array(‘class‘=>‘pagination‘),
        ),
        ‘dataProvider‘=>$dataProvider,
        ‘columns‘=>array(
       /*array(
          //添加复选框
                ‘htmlOptions‘=>array(‘width‘=>"30px"),
                ‘class‘ => ‘CCheckBoxColumn‘,
                ‘name‘=>‘checkbox[]‘,
                ‘value‘=>‘$data->id‘,
                ‘id‘=>‘checkbox‘,
                ‘headerTemplate‘=>‘{item}‘,
                ‘selectableRows‘=>2,
            ),*/ ‘id‘, array( ‘name‘=>‘status‘, ‘value‘=>‘$data->status == 0 ? "待审" : (($data->status == 1) ? "正常" : "屏蔽")‘ ), ‘email‘, ‘company_name‘, ‘company_full_name‘, ‘company_detail_addr‘, ‘login_ip‘, ‘last_login_time‘,
       /*array(
                //增删改查按钮
                ‘class‘=>‘CButtonColumn‘,
            ),*/ ), )); ?>

 解释:columns放置表的列名,itemsCssClass表的class属性,pager为分页

YII框架CGridView分页实现

标签:

原文地址:http://www.cnblogs.com/gdsn/p/4252756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!