Forum
09:51
Hello, I've been working with jqGrid 3.6.2 for a couple of days and noticed that I was not getting the pagination I expected. Here is my options object:
var options = {
jsonReader : {
root: "items",
page: "page", // pager
total: "total", // pager
records: "numRows", // pager
repeatitems: false,
cell: "items",
id: "inv_num",
userdata: "PHPSESSID"
},
prmNames: {
page:'page',
rows:'count',
sort:'sort'
},
[...postData and colModel here...]
mtype: 'GET',
colNames:['Inv #'],
datatype:"json",
height: '200',
autowidth: true,
shrinkToFit: true,
scroll: true,
sortname:'inv_num',
sortorder:"desc",
loadui: 'block',
altRows: true,
page: 1,
scrollrows: true,
url:'file.php'
};
Notice that my 'page' option is set to 1. I realize that this is the default. I noticed that on a data set that had 45 records, displaying 20 records would mean 3 pages (1-20, 21-40, 41-45). I noticed that when scrolling down, I could get page 1 and I could get page 2, but I could not get page 3. I thought perhaps this was due to my pagination calculation, so I changed 'page' to zero hoping it would fix the issue, but instead I observed getting page 0, then page 2, I was never able to get page 1.
I went back to page = 1 and manually increased my response to say that the total pages was 3+1. From there I was able to get page 1, 2 and 3.
I looked around in grid.base.js and found where it was (I think) calculating whether or not to grab another page. I found this condition on line 273 of that file:
(ttop <= 0 && tbot < dh &&
(p.lastpage==null||parseInt((tbot + scrollTop + div - 1) / div) < p.lastpage))
If I changed the operator to: '<= p.lastpage', I was able to get all of my pages leaving page = 1.
Can anyone confirm that this is an error, or am I doing something incorrectly? The only way I could further test was to verify that in fact the request for the last page was never actually being sent out. Making this change also fixed a spacing issue at the bottom of my grid (I presume to be height related?).
16:52
Moderators
30/10/2007
Hello,
Thank you very much for the investigation.
Currently I can not confirm that this is a bug. I will check with your settings and let you known.
Thanks again
Best 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:10
18/02/2010
Hi Tony,
I had the same problem. I think solution is pretty simple, if I change:
Ln279: //page = parseInt((tbot + scrollTop) / div) + 1; // Original code
to
Ln279: page = parseInt((tbot + scrollTop + div - 1) / div) + 1; //changed code
in grid.base.js, everything works fine.
Also I found a problem: when grid uses 'altrows:true' scrolling doesn't work. I did a workaround by adding
scrollTop -= (rows.outerHeight() - rows.innerHeight()) * rn;
after ln271.
Best Regards,
Eugeniu
09:53
Moderators
30/10/2007
Hello,
I need to test this.
Thanks.
Best 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.
Most Users Ever Online: 715
Currently Online:
68 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