首页 > 代码库 > YII框架CGridView sql有条件分页实现
YII框架CGridView sql有条件分页实现
$SQL="SELECT * FROM {{user}} WHERE `typeff`=2 order by create_time desc"; $SQL_count="SELECT count(*) FROM {{user}} WHERE `typeff`=2 order by create_time desc"; $count=Yii::app()->db->createCommand($SQL_count)->queryScalar(); $dataProvider=new CSqlDataProvider($SQL, array( ‘totalItemCount‘=>$count, ‘sort‘=>array( ‘attributes‘=>array( ‘id‘,‘email‘,‘company_name‘,‘company_full_name‘,‘company_status‘,‘company_dengji_step‘,‘company_verify_tel‘ ), ), ‘pagination‘=>array( ‘pageSize‘=>10, ), ));
$this->render(‘auditing‘,array( ‘dataProvider‘=>$dataProvider, ‘model‘=>$model, ));
V视图
$this->widget(‘zii.widgets.grid.CGridView‘, array( ‘id‘=>‘table-responsive‘, ‘itemsCssClass‘ => ‘table table-striped table-bordered table-advance table-hover‘, ‘pagerCssClass‘=>‘margin-top-20‘, ‘htmlOptions‘=>array(‘class‘=>‘table-responsive‘), ‘pager‘=>array( ‘class‘=>‘CLinkPager‘, ‘header‘=>‘‘, ‘htmlOptions‘=>array(‘class‘=>‘pagination‘), ), ‘dataProvider‘=>$dataProvider, ‘columns‘=>array( ‘id‘, ‘email‘, ‘company_name‘, ‘company_full_name‘, array( ‘name‘=>‘company_status‘, ‘value‘=>‘$data["company_status"] == 0 ? "待审" : "通过"‘ ), ‘company_dengji_step‘, ‘company_verify_tel‘, array( ‘header‘=>‘操作‘, ‘value‘=>‘createOperationHtmlForTable($data["id"])‘, ‘type‘=>‘html‘, ‘htmlOptions‘ => array(‘style‘ => ‘width:200px;‘), ) )));
效果图
YII框架CGridView sql有条件分页实现
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。