User Data

In some cases we need to have custom data returned from the request that is not automatically displayed by jqGrid, that we use either in a later process or to display additional information somewhere in the html page or associated with the grid. To do that a userdata tag can be used.

xmlReader: {userdata: "userdata",... }

In the data received from the server, this could be structured as follows (in xml):

<invoices> <request>true</request> <userdata name="totalinvoice"> 240.00 </userdata> <userdata name="tax"> 40.00</userdata> ... <result> <row> <cell>data1</cell> <cell>data2</cell> <cell>data3</cell> <cell>data4</cell> <cell>data5</cell> <cell>data6</cell> </row> ... </result> </invoices>

If using json data, the definition might look like this:

jsonReader : { ... userdata: "userdata", ... }

and the data received, like this:

{ total: "xxx", page: "yyy", records: "zzz", userdata: {totalinvoice:240.00, tax:40.00}, rows : [ {id:"1", cell:["cell11", "cell12", "cell13"]}, {id:"2", cell:["cell21", "cell22", "cell23"]}, ... ] }


When this data has been received, this information is stored in the userData array of the options array. Whichever format the data comes in, in this case we would have:

userData = {totalinvoice:240.00, tax:40.00}

The data can be accessed two ways.

  1. Using getReturnedData (provided by Paul Tiseo): this method directly returns the userData array

    jQuery("grid_id").getReturnedData()


  2. Using a getGridParam method. To do that we need to request this data:

    jQuery("grid_id").getGridParam('userData')

Both methods return the same array.



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