Forum
04:54
11/01/2013
Hello All,
I think I have found a bug in addRowData (grid.base.js), when using jqGrid with a local array.
If the rowid is not supplied, or does not exist in the source array, there is an attempt to fallback to the internal id generation mechanism, as follows (lines 2961-2962):
try {rowid = data[cnm];}
catch (e) {rowid = $.jgrid.randId();}
when data[cnm] does not exist Javascript (at least with the latest version of Chrome, Firefox IExplorer and a Web Browser (debian) 2.30.6) will not throw an exception for the assignment, so there is nothing to "catch".
The effect on the browser, is that the id of all the rows will be undefined. As such when the user clicks any row, the first row is selected (as the string "undefined" is assigned to all the rowids). The ids get populated properly if the rows are sorted (via a sortable column).
My temporary fix was to replace the two lines above with the following:
try { rowid = data[cnm];
if(rowid ===undefined) {
rowid = $.jgrid.randId();
}
} catch (e) {rowid = $.jgrid.randId();}
I don't think that the "fix" above breaks anything.
p.s.: Don't ask me why I used jqGrid with an array and an undefined id column…
Regards,
GeorgeG
Edited to correct late night/early morning typing errors 🙂
13:43
10/08/2009
I think that the line
can be fixed to
which is equivalent to (short form)
Best regards
Oleg
P.S. I suppose that Tony will make the corresponding changes in the code of jqGrid after reading of your bug report.
10:36
Moderators
30/10/2007
Hello,
Thank you for the bug fix.
Oleg I do not think that your fix is fine.
Suppose the rowid becomes 0 (data[cnm]=0), then the logic will go to randid which is not correct.
I think that the fix from GeorgeG is ok and I will implent this fix.
Thanks again
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:
63 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