The Server-side File

jqGrid can construct a grid from data in any of several formats, but the default is xml data with the following structure. Later we'll see how to use xml data in other structures and data in other formats.

Default xml Data Structure

<?xml version ="1.0" encoding="utf-8"?> <rows> <page> </page> <total> </total> <records> </records> <row id = “unique_rowid”> <cell> cellcontent </cell> <cell> <![CDATA[<font color=”red”>cell</font> content]]> </cell></row> <row id = “unique_rowid”> <cell> cellcontent </cell> <cell> <![CDATA[<font color=”red”>cell</font> content]]> </cell></row></rows>

The tags used in this example are explained in the following table.

Tag Description
rows the root tag for the grid
page the number of the requested page
total the total pages of the query
records the total records from the query
row a particular row in the grid
cell the actual data. Note that CDATA can be used. This way we can add images, links and check boxes.


The number of cell tags in each row must equal the number of cells defined in the colModel. In our example, we defined six columns, so the number of cell tags in each row tag should be six.

Note the id attribute in the <row> tags. While this attribute can be omitted, it is a good practice to have a unique id for every row. If this attribute is omitted, jqGrid has two ways of dealing with need for unique ids:

  1. if the property key in the colModel is set to true for a particular column, then jqGrid will assign the value of this column to be the id of the row; otherwise,
  2. jqGrid sets the row id based on the order of the row.

If you are using a content-free primary key to identify your data rows, then do not include this value in the grid as a visible cell; instead, include it in the query and pass it as the row id attribute. It will always be available for jqGrid and even jQuery operations but not be visible on the page.

Now it is time to construct our file.


  Last Updated: 8/8/2008 | © Tony's jqGrid - a jQuery Plugin, 2010