I am working on jqGrid, the return json is
{"total":1,"page":1,"records":2,"rows":[{"projectId":"1022","name":"john"}]}
then in the function I call
var jsongrid = eval("("+data+")");
var thegrid = jQuery("#projectList")[0];
thegrid.addJSONData(jsongrid);
but it give me error: object is null or undefined. don't know why . I didn't use json reader.
BTW, do you know how to use set method to set "total", "page", "records" ?
I suppose that you try to call
addJSONData
method before the grid will be created with respect ofjQuery("#projectList").jqGrid({...});
The usage of
addJSONData
is practically always unneeded (see one from my first posts about the subject here). In the same way you should never useeval
method which is evil. One uses jQuery.parseJSON or JSON.parse instead.I suppose that you should use
datatype: 'json'
to solve your problem. You should post more code to show you how you should use other jqGrid options in your case.UPDATED: From your previous question it seems that you want just send additional data to the server from the form on clicking of the "Search" button. In the case I would suggest to modify the code to the following
In the demo I get just the form from the example of the usage jQuery.serialize and modify it a little. It display the data which you need
Additionally, like you can easy verify with respect of Fiddler or Firebug, the URL will ba appended with additional parameters like below
The standard parameters
will be appended with parameters from the form
In some scenarios one can use jQuery.serializeArray alternatively. It allows to serialize the data in another format (like JSON) or convert the data in some another format (see here) which can be easy merged with the standard jqGrid parameters using $.extend.