【问题标题】:Editable hierarchical grid in Kendo UIKendo UI 中的可编辑分层网格
【发布时间】:2016-02-20 22:38:14
【问题描述】:

我希望创建一个网格,其中每一行都有网格。

两个网格都需要可编辑,我设法做到了。但是,当我尝试向外部网格添加新行时,其中的所有数据都消失了。

您可以在这里找到演示: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: "&nbsp;" }]
    });
};

【问题讨论】:

  • 点击创建按钮时是否会调用onExpansion,如果是,e.detailCell 是否指向现有的 dom 元素?
  • onExpansion 在我们第一次展开一行时被调用。 e.detailCell 是展开的行。
  • 如何添加新行?
  • 带有“工具栏:[“create”]”。这是剑道的特色。您可以在表格顶部看到“添加新记录”按钮。

标签: javascript kendo-ui grid hierarchy


【解决方案1】:

来自 Telerik 的回答:

请注意分页、排序、过滤等操作 编辑导致网格重新绑定并重新评估里面的所有模板 它(包括细节)。那为什么为了保护孩子 重新绑定之间的网格数据,您应该保存它以删除服务 (此处链接到文档)或将其添加为导航属性 集合到父 Grid 模型(此处提供演示)。

http://www.telerik.com/forums/hirarchialy-editable-grids

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2012-11-04
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    相关资源
    最近更新 更多