我们在添加新记录和编辑记录时遇到了Kendo UI内联网格的一些问题。添加新记录的问题如下:当我添加记录时,它将被添加到数据库中,但在页面刷新之前不会显示在网格上;如果是编辑:在刷新页面之前不会进行更新。 您可以在下面看到我正在使用的代码:
var crudServiceBaseUrl = window.location.href.split('?')[0];
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/GetList",
dataType: "json",
type: "GET",
contentType: "application/json; charset=utf-8"
},
update: {
url: crudServiceBaseUrl + "/Update",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
complete: function (e) {
$("#grid").data("kendoGrid").dataSource.read();
}
},
create: {
url: crudServiceBaseUrl + "/Create",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
complete: function (e) {
$("#grid").data("kendoGrid").dataSource.read();
}
},
parameterMap: function (options, operation) {
if (operation !== "read" && options) {
return JSON.stringify({ data: options });
}
}
},
pageSize: 20,
schema: {
data: "d",
model: {
id: "ListColId",
fields: {
ListColId: { editable: false, nullable: true, type:"number" },
ListId: {type:"number"},
ColumnTitle: { type: "string" },
DataFieldName: { type: "string" },
DataFieldId:{type:"number"},
Enabled: { type: "boolean" },
Ordering: { type: "number" },
CreatedOn: { type: "Date", editable: false }
}
},
type: 'json'
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
toolbar: ["create"],
columns: [
{field:"ListId",title:"List ID"},
{ field: "ColumnTitle", title: "Column Title", width: "120px"},
{ field: "DataFieldName", title: "Data Field name"},
{ field: "Enabled", title: "Enabled", width: "120px"},
{ field: "Ordering", title: "Order", width: "120px"},
{ field: "CreatedOn", title: "Created On", width: "120px", format: "{0:yyyy-MM-dd}"},
{ command: ["edit", "destroy"], title: " ", width: "250px" }],
editable: "inline"
});
提前感谢您帮助我!