简体   繁体   English

Kendo UI中的可编辑分层网格

[英]Editable hierarchical grid in Kendo UI

I wish to create a grid that each row has grid inside it. 我希望创建一个网格,每行内部都有网格。

Both grids need to be editable and I managed to do so. 这两个网格都需要可编辑,而我设法做到了。 However, when I try to add a new row to the outer grid, all the data inside it gone. 但是,当我尝试向外部网格添加新行时,内部的所有数据都消失了。

You can find the demo here: http://dojo.telerik.com/UqURE 您可以在此处找到演示: http : //dojo.telerik.com/UqURE

Can you please help with this issue? 您能帮忙解决这个问题吗?

Thanks! 谢谢!

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;" }]
    });
};

Answer from Telerik: Telerik的回答:

Please note that operations like paging, sorting, filtering and editing cause the Grid to rebind and reevaluate all templates inside it (including the details). 请注意,诸如分页,排序,筛选和编辑之类的操作会导致Grid重新绑定并重新评估其中的所有模板(包括详细信息)。 That why in order to preserve the child Grid data between rebinds you should either save it to remove service (link to documentation here) or add it as navigation property collection to the parent Grid model (demo is available here). 因此,为了保留重新绑定之间的子Grid数据,您应该将其保存以删除服务(此处链接到文档),或者将其作为导航属性集合添加到父Grid模型中(此处提供了演示)。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM