problem with two pagination on one page

HI ,

I have two pagination one one page ,

but issue is when i click on one pagination page the other gets pagination ,

i.e - when I click on page-3 of one pagination the other got page 3 too ,

please find screenshots …

change the pageVar for one of the paginations.

I believe the default is set to "page"(?page=NO) so you should set one of them to something else.

– No my friend , I have tried that but gives error.

– Not working … I have tried before , gives error.

More details!

What exactly did you try (code)?

And what error did it give you?

There is no reason it should not work, providing we are talking about two different widgets.

– The problem is as shown in first post thumbnails ,

I use widget CLinkPager for both pagination , I want both pagination on one page .

now when I click on any page number of widget it populates data of that page but second widget also populate data of that page.

means when i click page-3 of one pager the both pager populate data of page-3.

The thumbnails do not give details of the code you tried!

Let us assume that you are doing things the normal way - ie you are creating two CActiveDataProviders in your controller action and then passing them to the view to be rendered in two separate CGridView widgets.

In this case, all you should need to do is specify different pageVars when creating the CDataProviders, like so:


$dataProvider1=new CActiveDataProvider('Post', array(

    'criteria'=>array(

        'condition'=>'status=1',

        'order'=>'create_time DESC',

        'with'=>array('author'),

    ),

    'pagination'=>array(

        'pageSize'=>20,

        'pageVar' => 'list1',

    ),

));

$dataProvider2=new CActiveDataProvider('Post', array(

    'criteria'=>array(

        'condition'=>'status=2',

        'order'=>'create_time DESC',

        'with'=>array('author'),

    ),

    'pagination'=>array(

        'pageSize'=>20,

        'pageVar' => 'list2',

    ),

));

I use controller code somewhat like this …

public function actionIndex()

{


	$model=new LeaveSummary;


	$criteria = new CDbCriteria();


	$count=LeaveSummary::model()->count($criteria);


	$pages=new CPagination($count);


	$pages->pageSize=5;


	$pages->applyLimit($criteria);


	$leaveData  = LeaveSummary::model()->findAll($criteria);


	$this->render('index',array(


		'model'=>$model,


		'leaveData'=>$leaveData,


		'pages' => $pages,


		));


}

and below is the code I use on index view page …

<?php

$this->widget(‘CLinkPager’, array(

'pages' =&gt; &#036;pages,

)) ?>

– Now I use same code with different variables in controller for another pagination , Its working fine ,

but the problem is ‘pages’ => $pages, ( ‘pages’ variable pass in url and both pagination reflects ).

when I change ‘pages’ variable it gives error ,

is there any method to change ‘pages’ variable ( if yes then problem solved ) … … .

I use controller code somewhat like this …

public function actionIndex()

{


	&#036;model=new LeaveSummary;


	&#036;criteria = new CDbCriteria();


	&#036;count=LeaveSummary::model()-&gt;count(&#036;criteria);


	&#036;pages=new CPagination(&#036;count);


	&#036;pages-&gt;pageSize=5;


	&#036;pages-&gt;applyLimit(&#036;criteria);


	&#036;leaveData  = LeaveSummary::model()-&gt;findAll(&#036;criteria);


	&#036;this-&gt;render('index',array(


		'model'=&gt;&#036;model,


		'leaveData'=&gt;&#036;leaveData,


		'pages' =&gt; &#036;pages,


		));


}

and below is the code I use on index view page …

<?php

$this->widget(‘CLinkPager’, array(

'pages' =&gt; &#036;pages,

)) ?>

– Now I use same code with different variables in controller for another pagination , Its working fine ,

but the problem is ‘pages’ => $pages, ( ‘pages’ variable pass in url and both pagination reflects ).

when I change ‘pages’ variable it gives error ,

is there any method to change ‘pages’ variable ( if yes then problem solved ) … … .

All that seems fine to me, but I thought you said you were paginating two lists in one view - you’ve only shown me one here.

If indeed you are passing two lists to a view, but only one CPagination object then that cannot work.

For each list you will need to create an array of objects (with its own CDbCriteria object), and a CPagination object, and you should also force the pageVar for each CPagination object:


$pages1->pageVar = 'list1Page';

$pages2->pageVar = 'list2Page';

Pass these variables appropriately to your view, and render each pager with the appropriate $pages variable.