我刚刚开始使用Kendo UI,我尝试使用Kendo的DataSource来更新网格值,但检查后端PHP脚本是否设置为请求网址,似乎收到了请求,但没有POST参数
dataSource: {
transport: {
read: {
type: "POST",
url: "model/master_service2_data.php?sp_type=INQ",
dataType: "json"
},
update: {
url: "model/master_service2_data.php?sp_type=INS",
type: "post",
dataType: "json"
},
create: {
url: "model/master_service2_data.php?sp_type=INS",
type: "post",
dataType: "json"
},
parameterMap: function(options, operation) {
console.log(operation);
console.log(options);
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
schema: {
data: "data",
total: function (result) {
result = result.data || result;
return result.length;
},
model: {
id: "Paket_Detail_ID",
fields: {
Paket_ID: { type: "string" },
Paket_Detail_Desc: {type: "string"}
}
}
},
pageSize: 20
}
查看parameterMap函数中console.log的输出显示options.models不可用,这有关系吗? console.log(options)
确实显示了正确的POST参数,但服务器脚本
答案 0 :(得分:1)
正如dataSource API, the "models" parameter中提到的那样,仅当"批次" dataSource的选项已打开。在您当前的情况下,您应该直接将选项返回给服务器:
return {models: kendo.stringify(options)};