Kendo 在 Q3 2013 的 treeView 中添加了一个名为 expandPath
的新 API 方法。不幸的是,我在 Kendo UI Docs 或其论坛中找不到任何关于它的文档。
有人用过这个方法吗?一个样本会很棒。
最佳答案
好吧,它可以让您展开一条路径并提供一个回调,一旦所有节点都展开,该回调将被调用:
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 数组(按照您手动展开它们的顺序)。第二个参数是一个回调(这个参数是可选的),当从服务器加载额外的节点时,它可能主要有用(如果数组中的最后一个节点是叶节点,回调似乎不会被调用)。
(参见 demo)
关于javascript - Kendo treeview expandPath 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20921844/