好的,我已经研究了几天,并不确定我做错了什么。如果有人有将 jqGrid 与 C#/ASP.NET 和开源工具一起使用的工作示例,请告诉我在哪里可以找到它们。任何关于寻找体面的文档或工具的提示,我都可以用来调试它(我对 js/jQuery 很陌生)。基本上我只需要就地编辑功能,所以如果我忽略了另一个明显的解决方案,知道它可能会有所帮助......如果可能的话,我想避免使用 AJAX.NET。
我觉得我只是在这里忽略了一些非常明显的东西。
在下面的示例中,我确实显示了 jqGrid,但它没有显示任何数据。
以下是相关的 JavaScript:
jQuery(document).ready(function(){
jQuery("#role_assignment_table").jqGrid({
url:'http://localhost:4034/WebSite2/PageItemHandler.asmx/GetPageItemRolesJson?id=3',
mtype: 'GET',
contentType: "application/json; charset=utf-8",
datatype: "jsonstring",
colModel:[
{name:'Id', label:'ID', jsonmap:'Id'},
{name:'Title', jsonmap:'Title'},
{name:'AssignedTo', label:'Assigned To', jsonmap:'AssignedTo'},
{name:'Assigned', jsonmap:'Assigned'},
{name:'Due', jsonmap:'Due'},
{name:'Completed', jsonmap:'Completed'}
],
jsonReader: {
page: "Page",
total: "Total",
records: "Records",
root: "Rows",
repeatitems: false,
id: "Id"
},
rowNum:10,
rowList:[10,20,30],
imgpath: 'js/themes/basic/images',
viewrecords: false,
caption: "Role Assignments"
});
});
的HTML:
<table id="role_assignment_table" class="scroll" cellpadding="0" cellspacing="0" />
生成的 JSON:我不确定它是否进入 jqGrid,或者 jqGrid 是否不喜欢我的 JSON 或我的 WebMethod,但是当我转到正确的 URL 并获取 JSON 结果字符串时,我可以自己调用它.
{"Page":"1","Total":1.0,"Records":"4",
"Rows":[
{"Id":1,"Item":null,"Title":"Story Manager","AssignedTo":null,"Assigned":"\/Date(1245186733940-0500)\/","Due":"\/Date(1248383533940-0500)\/","Completed":"\/Date(1247087533940-0500)\/"},
{"Id":2,"Item":null,"Title":"Analysis","AssignedTo":null,"Assigned":"\/Date(1245186733940-0500)\/","Due":"\/Date(1248383533940-0500)\/","Completed":"\/Date(1247087533940-0500)\/"},
{"Id":3,"Item":null,"Title":"Narrative","AssignedTo":null,"Assigned":"\/Date(1245186733940-0500)\/","Due":"\/Date(1248383533940-0500)\/","Completed":"\/Date(1247087533940-0500)\/"},
{"Id":4,"Item":null,"Title":"Graphic","AssignedTo":null,"Assigned":"\/Date(1245186733940-0500)\/","Due":"\/Date(1248383533940-0500)\/","Completed":"\/Date(1247087533940-0500)\/"}
]
}
干杯,威廉·莱利-兰德