我有一个树面板,我在初始加载时设置了一些根级节点。然后当一个节点被打开时,我有一个javascript函数,它在其下面添加了子节点。appendChild树节点不扩展
我有一个问题,我无法让节点可扩展。它不显示箭头来展开节点。
下面是如何添加子节点:
var onbeforeitemexpand = function(node, options) {
if (!node.hasChildNodes()) {
node.appendChild({
title:'Should not be expandable',
checked: false,
leaf:true
});
node.appendChild({
title:'Should expand',
checked: false,
leaf:false,
expandable:true
});
};
tree.on('beforeitemexpand', onbeforeitemexpand, null);
但第二个孩子是不可扩展的。我可以得到它的可扩展的唯一方法是空的孩子加入到这样的:
node.appendChild({
title:'Should expand',
checked: false,
leaf:false,
expandable:true,
children:[{}]
});
但随后会有它下面一个空的节点,当我尝试在此节点下添加子时,它的扩展,子节点将进入空节点。
有没有更好的方法通过我自己的javascript函数(不通过ajax请求..)对树进行“延迟加载”?