Forum


13:05

30/09/2009

I am getting a strange error when I attempt to call addRowData after an ajax call in the grid. It says rows.length is null or not an object and it occurs in this line
if (t.rows.length === 0)
I'll post how i'm calling the grid as well, perhaps someone could help me decipher this.
$("#myDiv").jqGrid({
datatype: function(postdata) {
$.ajax({
type: "POST",
url: 'MYAJAXCALL',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(postdata),
complete: LoadComplete
});
},
height: 450,
colModel: [{ label: 'Field1', name: 'Field1', width: 100, resizable: false, sortable: true, align: 'center' },
{ label: 'Field2', name: 'Field2', width: 100, resizable: false, sortable: true, align: 'center' }],
hidegrid: false,
shrinkToFit: true,
altRows: true,
sortname: 'Fiedl1',
sortorder: "asc",
viewrecords: true,
caption: 'My Grid',
jsonReader: {
root: "Data",
page: "CurrentPage",
total: "TotalPages",
records: "TotalRecords",
userdata: "UserData",
repeatitems: false,
id: "0"
}, beforeSelectRow: function(id) {
return false;
},
onHeaderClick: function(state) {
},
gridComplete: function() {
}
});
function LoadComplete(jsondata, stat) {
if (stat == "success") {
var grid = $("#myDiv");
var jData = JSON.parse(jsondata.responseText, null).d;
if (jData.TotalRecords > 0) {
var jsonData = [];
$.each(jData.Data, function() {
var rowData = { Field1: this.Field1, Field2: this.Field2};
grid.addRowData(this.Field3, rowData)
});
} else {
grid.setGridHeight(25);
}
} else {
alert(jsondata.responseText);
}
}
Thanks in advance for the help
Most Users Ever Online: 715
Currently Online:
72 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