简介
我正在使用kendo-ui.Data使用web-api在网格中完美加载。我正在做的一件事是" Post"或创建新记录。我已使用This Example进行设置。
问题
现在,当我添加新记录/项目然后单击提交按钮(仅显示我的警报和控制台消息)时,我的插入失败,并且我没有相关的错误消息。我已经检查过模式,模态等但是再也找不到任何问题。
这可能是一个模态问题吗?
HTM
<div id="form-container">
<div class="demo-section k-content">
<input type='text' data-bind='value:Name' name='Project Name' />
<input data-value-primitive="true" data-source="dataSourceList" data-bind="value:Status" data-role="dropdownlist" />
<button data-bind="click: save" class="k-button k-primary">Submit</button>
</div>
</div>
修改后的脚本
var viewModel = kendo.observable({
dataSourceList: new kendo.data.DataSource({
transport: {
read:
{
url: crudServiceBaseUrl + "dropdown/projectstatus",
dataType: "json",
},
create: {
url: function () {
return crudServiceBaseUrl + "Project/?firmid=" + firmid + "&createdby=" + clientid
},
type: "POST"
},
batch: true,
schema: {
model: {
id: "ProjectId",
fields: {
ProjectId: { from: "ProjectId", editable: true, nullable: true, type: "guid" }
, Status: { from: "Status", editable: true, nullable: true, type: "string" }
, Name: { from: "Name", editable: true, nullable: true, type: "string" }
}
}
},
}
}),
save: function () {
this.dataSourceList.add({ Status: this.get("Status"), Name: this.get("Name")});
console.log(this.dataSourceList.add({ Status: this.get("Status"), Name: this.get("Name") }));
this.dataSourceList.sync();
console.log(this.dataSourceList.transport.options.schema);
},
});
kendo.bind($("#form-container"), viewModel);
控制台消息屏幕(在上面的代码中)
我已经尝试了一段时间,但无法解决这个问题。如果有人对此有所了解请帮助或任何参考,我们将不胜感激。感谢您的时间。