我必须将Web API(post)调用的结果绑定到kendo网格。结果格式为
{
"Id": 121,
"referenceId": 18222,
"status": null,
"message": "Completed"
}
API调用是:
read: {
url: //url,
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
},
parameterMap: function () {
return JSON.stringify({ Active: false });
}
},
schema: {
data:'data'
}
绑定:
$("#grid").kendoGrid({
dataSource: dataSource
columns: [{
field: "Id",
title: "Id"
}]
});
但它不起作用。 :(
答案 0 :(得分:1)
在参考中使用kendo.all.min文件。
使用此dataSource部分
schema: {
model: {
id: "Id",
fields: {
Id: { },
referenceId: { },
status: { },
message: {}
}
}
}
在网格侧使用此功能
$("#grid").kendoGrid({
dataSource: [{
"Id": 121,
"referenceId": 18222,
"status": "test",
"message": "Completed"
}],
navigatable: true,
pageable: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: [
{ field: "Id", title: "Unit Price" },
{ field: "referenceId", title: "Units In Stock" },
{ field: "status", width: 120 },
{ field: "message", width: 120 }
],
editable: true
});