jqGrid 在接收数据之前引发加载错误

jqGrid raises Load Error before receiving data

我有一个运行良好的 jqGrid,但我试图阻止它在页面加载时加载数据。我按照其他说明将数据类型设置为 'local',创建网格,然后使用 setGridParam。但是,在我更改网格参数并调用 reloadGrid 之后,我得到了一个 'Load Error',即使没有调用到达服务器。

function set_grid_params(){
    $("#current").setGridParam({postData:{emp:function(){return $("#employee").val();}}});
    $("#current").setGridParam({edit_url: #the api URL});
    $("#current").setGridParam({mtype:'GET', datatype:'json'});

    $("#current").trigger('reloadGrid');
}

#In main method
$("#current").jqGrid({
    name: "Current Balances",
    colNames: ["a","b","c"],
    colModel: [unimportant],
    datatype: 'local'
});

#do some other stuff to set $("#employee").  It is blank at page load,
# which is why I need to stop initial load, as the postData is empty.

set_grid_params();

弹出的对话框显示:

加载错误
-类型:parsererror
-响应:200
-OK

我从不在我的 API 方法的任何断点处停止,并且服务器日志没有显示任何请求到达 URL。我错过了什么?

您的示例设置了 edit_url 参数。可能您想改为设置 url 参数?顺便说一句,您可以一次调用 setGridParam 来设置您需要一次设置的所有属性,而不是调用该方法三次。