With the first release of jqGrid, the only possible way to obtain data was via XML as described in the tutorial above. Later, many people requested the ability to obtain data via JSON, then with an array and finally with 'real' names. After lot of work and with the help of the community we now have a wide range of methods for obtaining data.
The related options (in options array) for manipulating different types of data are:
Datatype: The possible options are - 'xml', 'json','clientSide' or 'local', 'xmlstring', 'jsonstring' and 'function (...)'.
The default mapping for XML data is as follows:
xmlReader : {
root: "rows",
row: "row",
page: "rows>page",
total: "rows>total",
records : "rows>records",
repeatitems: true,
cell: "cell",
id: "[id]",
subgrid: {
root:"rows",
row: "row",
repeatitems: true,
cell:"cell"
}
};
If your server can provide data in this structure, you need to do nothing more; but if not, there is a way (several ways) to handle the data you are given. See XML Data.
The default mapping for json data is as follows:
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: true,
cell: "cell",
id: "id",
subgrid: {
root:"rows",
repeatitems: true,
cell:"cell"
}
}
In colModel, the related options are xmlmap for the description of an xml field, and jsonmap for the description of a json field. For example:
colModel : [ {name:'amount',..., xmlmap:'amt'...}...]
will cause jqGrid to search in the xml data for an 'amt' tag (when the repeatitems option is set to false).