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
Bug in addJSONData ts.p.lastpage value wrong assigned
14/01/2010
12:17
Avatar
Klaus
Member
Members
Forum Posts: 68
Member Since:
18/11/2009
sp_UserOfflineSmall Offline
Hello!
I've found a bug occuring in the following situation ...
I'm using a grid with "true scrolling" (scroll: 1) activated.
In normal cases this does work correctly but if the server returns an empty table without any rows, the grid hangs in an endless loop of reloading the grid data.
The JSON data returned from the server for the grid is: {"page":1,"records":0,"rows":[],"total":0}
The problem seems that the grid variable "ts.p.lastpage" is set to 1 instead of 0 ("total":0).
I don't know why the grid then tries to load the data in an endless loop, maybe because of "true scrolling".
I didn't find a real problem in the grid code (v. 3.6.2), but have fixed the problem the following way (todo: cleanup fix):
addJSONData = function(data,t, rcnt, more, adjust) {
  ...        
  ts.p.lastpage= data[ts.p.jsonReader.total] || 1;
  log(["XXX: in addJSONData set lastpage=" + ts.p.lastpage, data, ts.p.jsonReader, ts.p.jsonReader.total, isDefined(ts.p.jsonReader.total), data[ts.p.jsonReader.total]]);
  if (typeof data[ts.p.jsonReader.total] == "undefined") {
    ts.p.lastpage = 1;
  } else {
    ts.p.lastpage = data[ts.p.jsonReader.total];
  }
  log("XXX: lastpage=" + ts.p.lastpage);
...
}
The log output of the modified code is the following:
XXX: lastpage=0
The assignment check or the short-circut-evaluation in "ts.p.lastpage= data[ts.p.jsonReader.total] || 1;" does not work!
"data[ts.p.jsonReader.total]" is defined and has the value 0 but the assigned result is 1.
for details see:
Logical OR (||) expr1 || expr2 Returns expr1 if it can be converted to true; otherwise, returns expr2. Thus, when used with Boolean values, || returns true if either operand is true; if both are false, returns false.
... a short-circut-evalution with value "0" is dangerous because "0" evaluates to "false", please check your code for similar problems.
Kind regards,
Klaus.
14/01/2010
22:17
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Klaus,

Thank you very much. I will do the needed.

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
80 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