Cgridview Ajax Pagination Back Button Issue

(Prashant Tyagi) #1

Hi there,

When user displays my CGridView, let’s say i am on page number 3 , and then click to display details of selected grid view item and then goes back with either pressing “Back” (tested in Firefox and IE) or by re-entering grid view’s view, he always gets first page and order by default can i retain the state of pagination.

please help me

(Alirz23) #2

by default it uses ajax for pagination you disable it by adding

<?php $this->widget('zii.widgets.grid.CGridView', array(



in your CGridView

(Softark) #3

If you are using Yii 1.1.11 or higher, then it may be worth trying ‘enableHistory’.

It should work with ajax.

(Prashant Tyagi) #4

thanks softark for your reply but i am using version can i do the same in this version?

thanks in advance

(Prashant Tyagi) #5

Hi alirz23

thanks for your reply but i have to do the same with ajax pagination. any other way?

(Abennouna) #6

There are jQuery plugins for that. And if you check CGridView’s latest source code, you can see ‘enableHistory’ property triggers this code:

/*lines 411-412*/



That’s the same plugin:

Pay attention to the requirements etc.

(Kris) #7


I got additional question related somehow (I use Yii 1.1.13). Imagine there is page with a CGridView with enabled history and pagination via ajax (displaying many pages):

  1. user goes to for instance page 3 in grid pagination

  2. then user goes to other url/page (not a grid page)

  3. then users clicks back button to go back to page with grid

Grid page will display first page results for a fraction of seconds and then it will load results via ajax for page 3? Does it it have to go to page 1 and then jump to page 3? IMO on back button it should go to 3 page results directly.



(Geinizhi) #8

I am using 1.1.10. I have the same question. Can someone shed some light?

(Abennouna) #9