对视图中所有表的分页效果yii

时间:2017-02-06 05:36:24

标签: php jquery ajax yii cgridview

我在视图页面中有两个表,使用Yii中的CGridView小部件。

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'property-grid',
    'itemsCssClass'=>'table table-hover table-nomargin table-striped grid-view table-responsive',
    'filter'=>$model,
    'dataProvider'=>$model->search_property(),    
    'enablePagination' => true,   
    'enableHistory'=>true,    
    'pagerCssClass'=>'dataTables_paginate paging_bootstrap table-pagination',
    'pager' => array('header'=>'','htmlOptions'=>array('class'=>'pagination')),
    'columns' => array(
        array(name=>'project_id','value'=>'$data["project_name"]','header'=>'Project','filter'=>CHtml::activeDropDownList($model,'project_id',CHtml::listData($model->selectProjectAll(),'project_id','project_name'),array('prompt'=>'All'))),
        array(name=>'flat_no','value'=>'CHtml::textField("flat_no",$data["flat_no"]."  ".$data["customer_name"],array("class"=>"gridfield"))','header'=>'Flat No','type'=>'raw'),
        array(name=>'type','value'=>'$data["type"]','header'=>'Type'),
        array(name=>'status','value'=>'$data["status_name"]','header'=>'Status','filter'=>CHtml::activeDropDownList($model,'status',CHtml::listData($model->selectstatustAll(),'id','status'),array('prompt'=>'All')),'htmlOptions' => array('style' => 'width: 120px;')),
    ),
    'htmlOptions'=>array('class'=>'table table-hover table-nomargin'),
))

另一张表

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'target-grid',
    'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',    
    'dataProvider'=>$model->sales_target_search(),
    'enablePagination' => true,
    'enableHistory'=>true,
    'pagerCssClass'=>'dataTables_paginate paging_bootstrap table-pagination',
    'pager' => array('header'=>'','htmlOptions'=>array('class'=>'pagination')),
    'columns' => array(
        array(name=>'user','value'=>'$data["username"]','header'=>'Executive'),
        array(name=>'from_date','value'=>'Yii::app()->dateFormatter->format("dd/MM/yyyy",$data["from_date"])','header'=>'From Date'),
        array(name=>'to_date','value'=>'Yii::app()->dateFormatter->format("dd/MM/yyyy",$data["to_date"])','header'=>'To Date'),
        array(name=>'target','value'=>'$data["target"]','header'=>'Target'),
        array('value'=>'$data["total"]','header'=>'Achieved'),
    ),
    'htmlOptions'=>array('class'=>'table table-hover table-nomargin'),
))

当我从分页中的第一页点击第2页时,它将转到第二页。但同时剩下的表格也会转到第二页。所以,如果我点击任何表格中的任何页面。该分页对视图页面中的所有表都有影响。如何防止分页,我点击表格。

1 个答案:

答案 0 :(得分:0)

最后我找到答案我只是删除了行'enableHistory'=>true,