Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Maintain row selection when changing page
25/10/2008
08:32
Avatar
Armorfist
Member
Members
Forum Posts: 20
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

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!

27/10/2008
08:13
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

I think you can do this by using some client persitence strategy like cookies..

29/10/2008
03:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Or simply use onPaging event to store selected Ids

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

29/10/2008
06:16
Avatar
Armorfist
Member
Members
Forum Posts: 20
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

Thanks for the suggestions, I have some ideas how to do this, when i'm done i'll post here.

12/03/2009
10:21
Avatar
Armorfist
Member
Members
Forum Posts: 20
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

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

12/03/2009
11:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

12/03/2009
12:11
Avatar
Armorfist
Member
Members
Forum Posts: 20
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

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/03/2009
12:40
Avatar
Armorfist
Member
Members
Forum Posts: 20
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

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

12/03/2009
18:32
Avatar
Armorfist
Member
Members
Forum Posts: 20
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
64 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information