| User | Post |
|
08:32 25/10/2008
| Armorfist
| | | |
| Member | posts 20 |
|
|
Hello,
Is it possible to maintain row selection when changing page with the pager?
On the example "SelectAll event" under "New in version 3.2″, if i select all elements from page 1, and move to page 2, the items on page 1 become deselected.
Thanks!
|
|
|
08:13 27/10/2008
| YamilBracho
| | | |
| Member | posts 124 |
|
|
I think you can do this by using some client persitence strategy like cookies..
|
|
|
03:34 29/10/2008
| tony
| | Sofia, Bulgaria | |
| Moderator
| posts 7041 |
|
|
Hello,
Or simply use onPaging event to store selected Ids
Regards
Tony
|
|
|
06:16 29/10/2008
| Armorfist
| | | |
| Member | posts 20 |
|
|
Thanks for the suggestions, I have some ideas how to do this, when i'm done i'll post here.
|
|
|
10:21 12/03/2009
| Armorfist
| | | |
| Member | posts 20 |
|
|
Hello again,
I tried doing this with the onSelectRow event and it works, the problem is i use the multiselect option that uses the onSelectAll event.
Unlike onSelectRow, that always returns the id weither you are selecting or deselecting, onSelectAll only returns the id's that you select. This is a problem because i can add the selected row's id to a cookie, but cannot remove them because i dont know which were removed.
Another problem is when i call the setSelection function to reselect the rows on page change, it calls the onSelectRow event, and because i'm using a code that works like toggle to add and remove id's from the cookie (if it exists removes it, else it adds it) it removes all of the selected id's.
I hope i made myself clear, here's the code i use so someone can take a look:
http://pastebin.com/m665ae618
Please ignore the messy code, its just a prototype.
Thanks,
Frederico
|
|
|
11:05 12/03/2009
| tony
| | Sofia, Bulgaria | |
| Moderator
| posts 7041 |
|
|
Hello,
Sorry for this, but there is undocumented parameter in onSelectRow -
onSelectRow(rowid, selected) – where the selected is valid only in multiselect mode and is true when the row is selected and false if delselected.
But as for the news you can read in the docs-
- Added a second parameter to setSelection: onselectrow (boolean, default true). If set to false, the onSelectRow is not launched
Hope this helps
Regards
Tony
|
|
|
12:11 12/03/2009
| Armorfist
| | | |
| Member | posts 20 |
|
|
Hello Tony,
Thanks for the fast reply.
That argument sure helps, but when I click on the top checkbox (the one that selects all the rows in that page) it doesnt call the onSelectRow event, instead, it calls the onSelectAll event. Is there a way to call the onSelectRow event anyway for each item when clicking this checkbox?
Edit:
I realised that onSelectAll also has that second argument, but it doesnt return the id's when deselected like onSelectRow.
Thanks,
Frederico
|
|
|
12:40 12/03/2009
| Armorfist
| | | |
| Member | posts 20 |
|
|
Ok, i hacked a line in grid.base.js and had the result i wanted:
After line 1296, i added:
ts.p.selarrrow[i]= ts.p.selrow = this.id;
And on line 1299, I commented:
ts.p.selarrrow = []; ts.p.selrow = null;
This way, the event onSelectAll has the same behaviour as onSelectRow.
If this doesnt break anything, I would like to resquest that it would be implemented in a future release.
As soon as it's ready, I will post the final code to maintain row selection when changing page.
EDIT:
Just realized it breaks getGridParam('selarrrow'), going to insert those results in a seperate array to return them.
Thanks for the help,
Frederico
|
|
|
18:32 12/03/2009
| Armorfist
| | | |
| Member | posts 20 |
|
|
Ok, its all working now. For those interested I posted the code on pastebin. You'll need the jquery cookie plugin:
Maintain selection changing pages: http://pastebin.com/f778c1db *UPDATED*
Little hack to the multiselect function. starts on line 1276 of grid.base.js (hope this gets included in future releases):
http://pastebin.com/f3ca5cfd6
I'm not really a javascript programmer, so any improvements are welcome. Please post them here.
Thanks to tony for all his support.
|
|