简体   繁体   English

多层网格层次结构-祖父母数据

[英]Multi-level grid hierarchy - grandparent data

At the transaction level of the hierarchy, I need access to a value from the #grid data. 在层次结构的transaction级别上,我需要访问#grid数据中的值。 Can this be passed as a parameter or must I traverse the DOM using jQuery? 可以将其作为参数传递,还是必须使用jQuery遍历DOM?

$(document).ready(function () {
    var element = $("#grid").kendoGrid({
        ...
        detailInit: summary
    });
});

function summary(e) {
    $("<div/>").appendTo(e.detailCell).kendoGrid({
        ...
        detailInit: transactions
    });
}

function tranasctions(e) {
    $("<div/>").appendTo(e.detailCell).kendoGrid({
        ...
    });
}

AFAIK, the detailInit event only provides masterRow property in its first argument object, which stands for the parent expanded row. 在AFAIK中, detailInit事件仅在其第一个参数对象(代表父级扩展行)中提供masterRow属性。 So I'm afraid you'll have to traverse it. 因此,恐怕您将不得不遍历它。 What I suggest is to store the masterRow in a data attribute in the second detail grid in order to find it in the last level: 我建议将masterRow存储在第二个详细信息网格的data属性中,以便在最后一级找到它:

Second level grid: 二级网格:

$(e.detailCell).kendoGrid({
    // settings ...
}).data("master", e.masterRow);

This will create a data attribute named "master" with the first expanded row. 这将在第一个扩展行中创建一个名为“ master”的数据属性。 Then in the third level you can retrieve it with: 然后,在第三级中,您可以使用以下方法检索它:

var root = $(e.masterRow).closest(".k-detail-cell").data("master");

Demo 演示版

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

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