Search code examples
phpjqueryajaxyiicgridview

Pagination effect on all tables in a view yii


I have two tables in view page, using CGridView widget in Yii.

$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'),
))

Another table

$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'),
))

When I click on page 2 from first table in pagination it will go to second. But the same time remaining tables also go to second page. So if I click any page from any table. That pagination is effecting on all table in a view page. How to prevent pagination other that I click the table.


Solution

  • Finally i found the answer i just remove the line 'enableHistory'=>true,