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_Related Related Topics sp_TopicIcon
Problem paging data when dataType is "local"
20/06/2011
14:57
Avatar
codecraig
Member
Members
Forum Posts: 6
Member Since:
06/06/2011
sp_UserOfflineSmall Offline

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.

20/06/2011
20:34
Avatar
codecraig
Member
Members
Forum Posts: 6
Member Since:
06/06/2011
sp_UserOfflineSmall Offline

My current work around is to "unbind" the click event from the pager buttons and then re-bind it and essentially copy/paste the code from the original click handler, with the exception that I keep track of the current page instead of deferring to "ts.p.page".

Cry

Forum Timezone: Europe/Sofia

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.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information