I Have a tree panel where I set some root level nodes on initial load. Then when a node is opened, I have a javascript function which adds child nodes under it.
I have a problem that I cannot get the node to be expandable. It doesn't show the arrow to expand the node.
Here's how I add the child nodes:
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);
But the second child is not expandable. The only way I can get it to be expandable is to add empty children to it like this:
node.appendChild({
title:'Should expand',
checked: false,
leaf:false,
expandable:true,
children:[{}]
});
But then there will be a empty node underneath it and when I try to add children under this node when it's expanded, the child nodes will go inside the empty node.
Is there some better way to do "lazy loading" of the tree via my own javascript function (not via ajax request..)?