Cgridview + Ccheckboxcolumn - Selecting More Rows On More Pages


I created CGridView that shows cca 50 items per page, but totally there are 1500 items. I need to check (select) for example 200 rows and print them to PDF. But how can I select items on more pages using CCheckboxColumn?

The only solution that crosses my mind is to catch the event when checkbox on each row is checked and save to DB (or to session) some value indicating that this row will be printed. But how do I know which checkbox was unchecked so I can remove it from the list?

Important: Not all rows have checkbox. Not all records can be printed at the moment.

But what if user selects all available items on current page by clicking the checkbox in header? How do I know which rows where checked and unchecked? Is there some event for this? I need to store checked rows, allow user to switch page, check more rows and than print for example 85 rows at once.

Second solution could be to create a buffer in session and to move all checked rows to it by pressing a special button. When selection is done, printing can begin. But it is not comfortable.

var list = $.fn.yiiGridView.getChecked('CGridID','ColumnId');



  // do something


CGridID and ColumnId were set by attribute id:


Any ideas please?

There are two options that come into my mind:

  1. Allow the user to select the amount of items displayed on one page (or set it to a higher static number)

  2. Split up the process in two steps. In the first step you only set/remove a "print" flag to the records that the user selected on the GridView while in a second step you allow to print all flagged records (which is bascily the same solution as yours, but requires an explicit form submission)

Your solution would require to handle an "onChange" event of the checkboxes which then triggers an ajax request to the server. Also, to give the user a visual feedback you should display a spinner while the request is running (and a checkmark afterwards to signal success). In my opinion thats too much work for such a small archivement.

Thanks Coksnuss for ideas. Now it works as you mentioned in 1). Page is larger and user can print only items from the current page.

I will give it more time, maybe I will come with some user friendly solution, which is always hard. Our users sometimes do not understand what they should do even if it is absolutely obvious :)