Reputation: 14882
Let's say I have a perfectly fine JSON serialized string, like so:
{"Page":0,"Total":0,"Records":0,"Rows":[{/*blah*/}]}
This isn't returned by a particular URL, it's just sitting there, happy as it can be (harcoded). How do I add it to jqGrid? I've tried every conceivable variation of the loadComplete
function or a addJSONData
variant, latest:
loadComplete: function(){
var mygrid = jQuery("#grid")[0];
var o = eval("(" + {"Page":0,"Total":0,"Records":0,"Rows":[{/*blah*/}]} + ")");
mygrid.addJSONData(o.result);
}
but it won't work. It has worked when I've returned the JSON by a URL, however. Am I missing something when I use:
dataType:"json",
url: "/SomePageThatDoesntDoAnything"
I have a sneaky feeling it might have to do with having to reload the grid. Any help will be greatly appreciated.
Upvotes: 1
Views: 8690
Reputation: 21
check this link: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data
you need to set up the following jqgrid properties:
datatype: "jsonstring",
datastr : JSON.stringify(JSON_OBJECT, function replacer(key, value){return value});, //
JSON.stringify function is defined on the json.org site.
Upvotes: 2