我在使用setGridParam设置jqgrid的url时遇到了一些问题.
我收到消息:"f未定义".
我的设置:
$("#prices").jqGrid({
colModel: [
...
],
pager: jQuery('#pricePager'),
ajaxGridOptions: { contentType: "application/json" },
mtype: 'POST',
loadonce: true,
rowTotal: 100,
rowNum: -1,
viewrecords: true,
caption: "Prices",
height: 300,
pgbuttons: false,
multiselect: true,
afterInsertRow: function (rowid, rowdata, rowelem) {
// ...
},
beforeSelectRow: function (rowid, e) {
// ...
},
onSelectRow: function (rowid, status) {
// ...
}
});
Run Code Online (Sandbox Code Playgroud)
获取数据:
$("#prices").setGridParam({ datatype: 'json', page: 1, url: '@Url.Action("GridDataPrices")', postData: JSON.stringify(selections) });
$("#prices").trigger('reloadGrid');
Run Code Online (Sandbox Code Playgroud)
响应是非编码的json:
{"total":1,"page":1,"records":100,"rows":[{"id":160602948,"StartDate":"\/Date(1311717600000)\/","Duration":7,"Price":1076.0000,"Code":"code"},{"id":160602950,...}]}
Run Code Online (Sandbox Code Playgroud)
但是,我使用firebug得到以下消息:
"f未定义"
我首先使用addJSONData,但必须替换它,因为我想保留本地排序.
提前致谢.
上传代码后,所有内容都将清除.你的主要错误是以下几点:
datatype: 'local'在jqGrid中.默认值为'xml'.jsonReader: { repeatitems: false }(有关详细信息,请参阅文档)colModel在JSON数据中使用"ArivalCodeWay" 和"ArrivalCodeWay".所以你应该修复相应的jqGrid列的名称date从"\/Date(1312840800000)\/"您应该包含formatter:'date'在相应列中的格式解码.formatter:'int', sorttype:'int'在"持续时间"列和sorttype:'number', formatter:'number', formatoptions: { decimalPlaces:4, thousandsSeparator: "," }"价格"列中.JSON.stringify,则应包含json2.js以确保您的代码可以在所有Web浏览器中使用.您可以在此处找到修改后的演示(包括其他一些小改动).如果单击"单击我"按钮,将加载网格包含.
| 归档时间: |
|
| 查看次数: |
17110 次 |
| 最近记录: |