I have recently made extensive use of jqgrid for a prototype project I am working on for CB Richard Ellis (my employer). There are many way to populate a jqgrid, as noted in the documentation: (see the "retrieving data" node).
Currently I make a service call that returns a json string that when evaluated, gives me an object that contains the following:
In my success callback, I manually create the jqgrid like this: ("data" is the object I get when evaluating the returned json string).
var colNames = data.ColumnNames;
var colModel = data.ColumnModels;
var previewData = data.PreviewData;
var totalRows = data.TotalRows;
var sTargetDiv = userContext[0]; // the target div where I'll create my jqgrid
$("#" + sTargetDiv).html("<table cellpadding='0' cellspacing='0'></table>");
var table = $("#" + sTargetDiv + " > table");
table.jqGrid({
datatype: 'local',
colNames: colNames,
colModel: colModel,
caption: 'Data Preview',
height: '100%',
width: 850,
shrinkToFit: false
});
for (var row = 0; row < previewData.length; ++row)
table.addRowData(row, previewData[row]);
So you can see I manually populate the data. There is more than 1 kind of server error. There is the logical error, which you could return as a property in your json string, and check before you try to create a jqgrid (or on a per-row basis).
if (data.HasError) ...
Or on a per-row basis
for (var row = 0; row < previewData.length; ++row)
{
if (previewData[row].HasError)
// Handle error, display error in row, etc
Another thing to remember/ or that I found is that if you are using Asp.net you need to turn
in the section - this will allow you to introspect the Message coming back as well.