【发布时间】:2016-01-07 09:46:36
【问题描述】:
grid.jqGrid({
datatype: "json",
url: "Industry.aspx/GetAllRecords",
datatype: "json",
mtype: 'POST',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
serializeGridData: function (posData) {
//alert(JSON.stringify(posData.d));
return JSON.stringify(posData);
},
colNames: ['', 'Code', 'Description', 'Description2', 'Active'],
colModel: [
{ name: 'action', index: 'action', width: 45, sortable: false },
{ name: 'IndustryCd', width: 80 },
{ name: 'IndustryDs', width: 200 },
{ name: 'IndustryDs2', width: 200 },
{ name: 'active', width: 50,
editoptions: { value: '1:0' },
formatter: 'checkbox', formatoptions: { disabled: false}
}
],
height: 'auto',
gridview: true,
loadonce: false,
id:'IndustryCd',
jsonReader: {
repeatitems: false,
root: function (obj) {
alert(obj.d);
return typeof obj.d === "string" ? $.parseJSON(obj.d) : obj.d;
},
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.length; }
},
loadComplete: function () {
}
});
JSON 数据
d=[
{
"IndustryCd": "1",
"IndustryDs": "Manufacture",
"IndustryDs2": "",
"Active": true
},
{
"IndustryCd": "2",
"IndustryDs": "Sales",
"IndustryDs2": "",
"Active": false
}
]
【问题讨论】:
-
欢迎来到 StackOverflow。请先查看 StackOverflow 关于提问的帮助。关注How to ask a good question 和How to create a Minimal, Complete, and Verifiable example,但其他help topics 也会很有用。
-
你的问题根本不包含任何问题。另外,请描述预期行为和实际行为。
标签: jquery jqgrid jqgrid-formatter