Function

This option does not really define the datatype at all, but rather how to handle the data that is provided by the server (which would still come as either xml or json data). The functions defined as a Datatype should (or can) call addXMLData or addJSONData once the data has been received.

Calling Convention:

datatype : function(postdata) { // do something here }

Datatype functions are supplied with a single object containing the request information (parameter postdata), which normally would have been transformed into GET or POST arguments. This object is compatible with the data: option supplied to the jQuery $.ajax function.

Example:

jQuery("#"+gridid).jqGrid({ ... datatype : function(postdata) { jQuery.ajax({ url:'server.php', data:postdata, dataType:"xml", complete: function(xmldata,stat){ if(stat=="success") { var thegrid = jQuery("#"+gridid")[0]; thegrid.addXmlData(xmldata.responseXML); } } }); }, ... });


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