jqGrid 一直在踢我的屁股(以及本网站上的其他人)。使用 addJSONData 方法时,我似乎无法从 web 服务获取 JSON 数据以加载到 jqGrid 中。
有谁知道这是否可行?我不使用 MVC,只是在 ASP.NET 3.5 中使用普通的 WebProject Web 服务。
我正在使用最新版本的 jqGrid 3.5。
我不知道该怎么办。我目前正在尝试仅加载 1 行,我在我的 WS 中返回一个字符串,如下所示:
"Page:1,Total:1,Records:1,Rows:[name: Jeff V title: Programmer]"
然后将其传递到我的javascript中: {"d":"Page:1,Total:1,Records:1,Rows:[name: Jeff Vaccaro title: Programmer]"}
我的 jQuery 代码如下:
jQuery(document).ready(function () {
jQuery("#list").jqGrid({
datatype: processrequest,
mtype: 'POST',
colNames: ['Name', 'Title'],
colModel: [
{ name: 'name', index: 'name', width: 55 },
{ name: 'title', index: 'title', width: 90 }
],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'id',
sortorder: "desc",
viewrecords: true,
imgpath: 'themes/basic/images',
caption: 'My first grid'
});
});
function processrequest(postdata) {
$(".loading").show();
$.ajax({
type: "POST",
data: "{}",
datatype: "clientside",
url: "../webServices/myTestWS.asmx/testMethod",
contentType: "application/json; charset-utf-8",
complete: function (jsondata, stat) {
if (stat == "success") {
jQuery("#list")[0].addJSONData(eval("(" + jsondata.responseText + ")"));
$(".loading").hide();
} else {
$(".loading").hide();
alert("Error with AJAX callback");
}
}
});
}
我已经尝试了 addJSONData 代码的各种不同变体。有谁知道这是否可行?
任何帮助表示赞赏!
谢谢