Reputation: 9018
While using jqGrid's getCell method, it always returns me undefined in IE8. On Mozilla it works fine.
$('#grid').jqGrid('getCell',id,column); //returns undefined in IE8 :(
Should I use the method defined in this answer instead.
function getCellValue(rowId, cellId) {
var cell = jQuery('#' + rowId + '_' + cellId);
var val = cell.val();
return val;
}
What is the best approach? I have treegrid implemented and am using version 4.3.1 of jqGrid.
My configurations is
var grid = $("#grid").jqGrid({
treeGrid: true,
treeGridModel: 'adjacency',
ExpandColumn: 'businessAreaName',
ExpandColClick : true,
url:'agileProgramme/records.do',
datatype: 'json',
mtype: 'GET',
colNames:['Id'
, 'Business Area'
, 'Investment'
, 'Org'
, 'Goal'
],
colModel:[
/*00*/ {name:'agileProgrammeId',index:'agileProgrammeId', width:0, editable:false,hidden:true},
/*01*/ {name:'businessAreaName',index:'businessAreaName', width:160, editable:false},
/*02*/ {name:'programmeName',index:'programmeName', width:150, editable:false, classes:'link'},
/*03*/ {name:'org',index:'org', width:50, editable:false, classes:'orgHierarchy', sortable : false},
/*04*/ {name:'goal',index:'goal', width:70, editable:false}
],
treeReader : {
level_field: "level",
parent_id_field: "parent",
leaf_field: "leaf",
expanded_field: "expanded"
},
autowidth: true,
height: 240,
pager: '#pager',
sortname: 'id',
sortorder: "asc",
toolbar:[true,"top"],
caption:"TableGridDemo",
emptyrecords: "Empty records",
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "agileProgrammeId"
}
});
Thanks Oleg for the response. I found the root cause of the problem. It is in the $.unformat method of jqGrid.
return ret !== undefined ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html());
I changed it to
return (typeof ret != 'undefined') ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html());
Actually the ret !== undefined
is not working in ie8. Once, I changed it to typeof ret != 'undefined'
, it worked like expected.
Upvotes: 0
Views: 1561
Reputation: 222017
I supposed that you used getCell
in the wrong place. The most safe place to use getCell
in in loadComplete
or inside of some other callback. In case situation you are sure that the data which you try to read are already in jqGrid. IE8 is much slowly as other web browsers so I can only suppose that even you used getCell
in the wrong place the modern browsers are already read the grid contain and so your tests were successful.
The demo I made based on the code which you previously posted. It read 'programmeName' from the first loaded row with respect of getCell
and display it with respect of alert
. How you can verify the code works without any problem in IE8.
Upvotes: 1