Best Practice for multiple and non-standard placement of CDataGrid pager

Hi Yii Community. There are many topics is the docs, wiki, and forum about the CDataGrid pager. I have searched all and cannot seem to find a solution within the methods provided to me in the Data Grid.

My Problem: I have requests from clients to either move the pager to strange places on the page. Or to include multiple pagers for one data grid (i.e. one request was to have a pager at top and bottom)

I have searched and admit there is a lot of discussion about the pager, but non e of the problems/solutions seem to be close to mine.

My solution: I used jQuery .clone or .detach to move or to clone pagers around the DOM. So, for instance, I may write something like this:


While this single line of code works for what my client wants, I am wondering about best practice or using Yii Framework’s methods to address client requests. Surely, I thought, someone has wanted multiple pagers or to move the pager. I can’t find anything directly related to that.

Forgive, if I missed an older topic or didn’t go deeply enough into the pages of the search request to find the solution. BUT, how is the BEST WAY to do it? Thx!

For having multiple pagers you can use the template property -

Just use the token {pager} more times, like ‘template’ => ‘{pager}{items}{pager}’

as for having the pager separate from the grid there is no property for that so your solution is good.

Awesome! Works good! Thanks! The template method is a good find, too. I can see how it could be very useful for a variety of layouts and customization efforts.

I kind of figured a pager outsider the parent wrapper element might have to be handled by another library, like jQuery.