Forum
22:58
01/04/2011
We use jqGrid extensively, and one of the things we often do is have homegrown jQuery widgets appear as lightboxes or dialogs after being clicked on in a grid containing updatable forms for the selected record. Our grids are paged; we don't use updatable grids because the data itself is very extensive and we only show a subset of the record in the form for browsing.
What we recently wanted to add to these widgets is the ability to go forward and backward in the list of records. So say I have a list of 80 records and I show 20 per page; if I click on the first one to bring up a detail widget, a "Next" button would be available and clicking on it would get the ID of the next record and load that into the widget.
What we found in doing this however is that the jqGrid plugin only readily allows access to the IDs that are in the current page, even when we use loadonce. We could do some hacking around and have the rowNum changed to some large value, pull the data out, then change it back, but that seems like a lot of overhead. Intercepting the data from the original Ajax call or load events before the records are sliced doesn't work because of sorting - when the data is sorted it appears that it's only available as a full sorted list of objects very briefly in the addLocalData function.
What I ended up doing is adding a custom "event" in my code called onSortComplete, which passes this full sorted data from the sort query to the event handler when present. In my local copy of the 4.2.0 jqGrid this is around line 1550, right before this:
// added: event that passes the sorted list if ($.isFunction(ts.p.onSortComplete)) { try { ts.p.onSortComplete.call(ts, queryResults); } catch (e) { } } queryResults = queryResults.slice( (page-1)*recordsperpage , page*recordsperpage );
I don't know if this makes sense to add in, or consider at least. And I only use it for my "loadonce" style grids that I do client-side sorting on. But it was helpful to me, so I wanted to post it here.
Most Users Ever Online: 715
Currently Online:
54 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66