当JSON数据在静态文件中时,我的jqgrid可以工作,但是如果我将数据复制到var,然后尝试将var加载到jqgrid的URL中,它就不会显示出来。
你能把一个字符串传给jqgrid吗
例如
这工作:
function GetJSON() {
var jsonFile = "EntityWithChildren.json";
return jsonFile;//returning a file works fine.
}
$("#jsonmap").jqGrid({
url: GetJSON(),
datatype: 'json',
这不是:
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',//this doesnt work either