剑道树视图展开路径方法



>Kendo 在 2013 年第 3 季度在其 treeView 中添加了一个名为 expandPath 的新 API 方法。不幸的是,我在剑道UI文档或其论坛中找不到任何有关它的文档。

有人用过这种方法吗?样品会很棒。

好吧,它允许您扩展路径并提供一个回调,一旦所有节点都展开,就会调用该回调:

var tree = $("#treeview").kendoTreeView({
    dataSource: [{
        id: 0,
        text: "Furniture",
        items: [{
            id: 1,
            text: "Tables & Chairs"
        }, {
            id: 2,
            text: "Sofas"
        }, {
            id: 3,
            text: "Occasional Furniture",
            items: [{
                id: 8,
                text: "Small Sofas"
            }, {
                id: 9,
                text: "Tiny Sofas",
                items: [{
                    id: 10,
                    text: "Small Tiny Sofas"
                }, {
                    id: 11,
                    text: "Smallest Tiny Sofas"
                }]
            }]
        }]
    }, {
        id: 4,
        text: "Decor",
        items: [{
            id: 5,
            text: "Bed Linen"
        }, {
            id: 6,
            text: "Curtains & Blinds"
        }, {
            id: 7,
            text: "Carpets"
        }]
    }]
}).data().kendoTreeView;
tree.expandPath([0, 3, 9], function() {
    console.log("hello");
});

第一个参数是描述路径的节点 ID 数组(按照手动展开它们的顺序)。第二个参数是回调(此参数是可选的),这可能主要在从服务器加载其他节点时有用(如果数组中的最后一个节点是叶节点,则似乎不会调用回调)。

(见演示)

最新更新