My jqGrid is work when my JSON data is in a static file, but if I copy the data to a var and then try to load the var into the jqGrid's url it doesn't show.
Can you pass a string into jqGrid
e.g. This works:
function GetJSON() {
var jsonFile = "EntityWithChildren.json";
return jsonFile;//returning a file works fine.
}
$("#jsonmap").jqGrid({
url: GetJSON(),
datatype: 'json',
this doesn't:
function GetJSON() {
var json = '{"page":"1","total":"10", "records":"10", "Entities": [ {"Fields":["Entity1", "field1", "11"]}, {"Fields":["", "field2", "22"]}, {"Fields":["Entity2", "field3", "33"]}, {"Fields":["ChildEntity1", "cfield1", "111"]} ]}';
return json; //doesnt work
}
$("#jsonmap").jqGrid({
url: GetJSON(),
datatype: 'json',
//datatype: 'jsonstring',/开发者_如何学Go/this doesnt work either
got it. need to use datastr instead of url
datatype: 'jsonstring',
datastr: GetJSON(),
精彩评论