Post edited 12:04 – 11/01/2013 by GeorgeG
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