[英]Editable hierarchical grid in Kendo UI
我希望創建一個網格,每行內部都有網格。
這兩個網格都需要可編輯,而我設法做到了。 但是,當我嘗試向外部網格添加新行時,內部的所有數據都消失了。
您可以在此處找到演示: http : //dojo.telerik.com/UqURE
您能幫忙解決這個問題嗎?
謝謝!
var outerDataSource= new kendo.data.DataSource({
schema: {
model: {
field1: { type: "string", validation: { required: true } },
field2: { type: "boolean", validation: { required: true } },
field3: { type: "string", validation: { required: true } }
}
}
});
$("#outerGrid").kendoGrid({
dataSource: outerDataSource,
detailInit: onExpansion,
toolbar: ["create"],
columns: [
{ field: "field1", title: "field1" },
{ field: "field2", title: "field2" },
{ field: "field3", title: "field3" },
{ command: ["destroy"], title: " " }],
editable: true
});
function onExpansion(e) {
var insideDataSource= new kendo.data.DataSource({
schema: {
model: {
in1: { type: "string", validation: { required: true } },
in2: { type: "string", validation: { required: true } }
}
},
data: [{
in1: "Click to edit",
in2: "Click to edit"
}]
});
var headers = $("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: insideDataSource,
width: 90,
toolbar: ["create"],
editable: true,
columns: [
{ field: "in1" },
{ field: "in2" },
{ command: ["destroy"], title: " " }]
});
};
Telerik的回答:
請注意,諸如分頁,排序,篩選和編輯之類的操作會導致Grid重新綁定並重新評估其中的所有模板(包括詳細信息)。 因此,為了保留重新綁定之間的子Grid數據,您應該將其保存以刪除服務(此處鏈接到文檔),或者將其作為導航屬性集合添加到父Grid模型中(此處提供了演示)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.