我是jsgrid的新手,我想知道自己在做错什么。
如果我在页面中填充一个JavaScript数组,则可以向网格加载数据。但是,我无法从远程Web服务加载网格数据。
这是页面加载到客户端时的我的JavaScript代码(类似于在here上找到的代码):
$("#table1").jsGrid({
width: "100%",
inserting: true,
editing: true,
sorting: true,
paging: true,
filtering: true,
autoload: true,
pageSize: 12,
pageButtonCount: 5,
noDataContent: "No data was found",
deleteConfirm: function(item) {
return "Do you really want to delete the IPv4 address " + item.IPv4Address + "?";
},
controller: {
loadData: function() {
var d = $.Deferred();
$.ajax({
type: "POST",
url: "proxy_ws.php",
data: "action=getdata",
dataType: "json"
}).done(function(result) {
console.log("get data (done): ", result);
console.log("get data value (done): ", result.value);
// d.resolve(result.value);
d.resolve(result);
});
return d.promise();
}
},
fields: [{
name: "IPv4Address",
title: "IPv4 Address",
type: "text",
width: 120,
validate: "required"
}, {
name: "Timeout",
title: "Timeout",
type: "number",
width: 50
}, {
name: "Description",
title: "Description",
type: "text",
width: 200
}, {
name: "Signature",
title: "Signature",
type: "text",
width: 50,
editing: false
}, {
type: "control"
}]
});
Firefox的控制台显示以下消息:
获取数据(完成):对象{IPv4Address:“ 10.215.144.48”,超时:300,描述:“这是一个测试。”,签名:“ no sig ...”}测试:380:11 获取数据值(完成):未定义
很明显,“ proxy_ws.php”上的Web服务输出:
{"IPv4Address":"10.215.144.48","Timeout":300,"Description":"This is a test.","Signature":"no sig..."}
但是,网格中没有任何内容。 格式不正确吗?
顺便说一句,我没有在网上找到有效的演示。
谢谢