使用jsGrid
我试图从我的服务器显示信息。因此,我收到数据的格式为:
{
"Response": [
{
"this": "1",
"that": 42,
"theOtherThing": "2016-01-28T19:45:19.093Z"
},
{
"this": "2",
"that": 49,
"theOtherThing": "2016-01-28T19:45:19.093Z"
}
]
}
如何从对象响应中提取此信息,以便我可以在jsGrid
字段中显示该信息?
fields: [
{name: 'this', type: 'text', width: 100},
{name: 'that', type: 'number', width: 100},
{name: 'theOtherThing', type: 'text', width: 100}
]
答案 0 :(得分:1)
所以我只需要改变我的ajax调用的格式:
controller: {
loadData: function () {
var deferred = $.Deferred();
$.ajax({
type: 'GET',
url: 'ThisGoesSomewhere',
dataType: 'json',
success: function(res){
deferred.resolve(res.Response);
},
error: function(res){
console.log('error ' + res);
}
});
return deferred.promise();
}
}