首页 > 代码库 > YII框架CGridView分页实现
YII框架CGridView分页实现
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分页实现
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。