Forum
14:57
06/06/2011
I'm using a local data grid (e.g. datatype: 'local') and when the user clicks one of the paging buttons (first, previous, next, last) I need to kick off a request to the server to get data.
I'm having a slight problem where it seems the grid isn't updating the current page number (or I'm not doing it properly). Initially I fetch the first page of data and the grid displays it, everything looks fine. Then I click on the "next" button and my "onPaging" event handler sees that the user wants to get page 2:
var requestedPage = $('#mygrid').jqGrid('getGridParam', 'page');
goFetchData(requestedPage);
When the data is returned from the server I am trying to update the grid by doing this:
setData: function(data) {
var reader = {
root: function(obj) { return data.rows; },
page: function(obj) { return data.page; },
total: function(obj) { return data.total; },
records: function(obj) { return data.records; },
repeatitems: false
};
$('#mygrid').jqgrid('setGridParam', {
data: data.rows,
localReader: reader
}).trigger('reloadGrid');
}
So after getting page 2 and updating the grid, everything looks right (i.e. grid shows proper data, pager shows "page 2 of 34", etc).
Now when I click the "previous" button nothing happens, my "onPaging" event handler is not being invoked. I looked a the jqGrid source and saw the "click" event handler for the pager buttons does some checking of the values before invoking my callback. So, I put a print statement in to see what it thought the current page number was:
$(
"#first"+tp+", #prev"+tp+", #next"+tp+", #last"+tp,"#"+pgid).click(function(e) {
var cp = intNum(ts.p.page, 1),
.....
console.log("Current page is " + cp);
..
}
What I see in the firebug console is "Current page is 1", which isn't correct. I verified that the grid has the correct page number by invoking: $('#mygrid').jqgrid('getGridParam', 'page')...but it seems that the "ts.p.page" variable in the click handler (inside jqgrid source) is "stale".
Any ideas?? I'm using jqGrid 4.0 (release 2011-04-09).
Thanks.
Most Users Ever Online: 715
Currently Online:
62 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