In the comments for this.setExpanded() in HTreeNode, you have this example:
* aboutToExpandOrContract = function( expanding, treeNode )
* {
* if ( expanding && treeNode.children.length == 0 )
* // children initially defined with zero length array
* {
* var a = [];
* // ... code to fetch children and populate 'a'
* treeNode.children = HTree_makeNodes( a );
* }
* }
I have been unable to get this to work. Can you give a more complete example, perhaps a modification to htreedemo.js?
Also, it's implied that this needs to be added to every single data item (if my tree is fully expanded, I have hundreds, and it could go into the thousands), which could be... problematic. I've made a few changes to the source, introducing a "hasChildren" flag and basing isLeaf() off of that rather than children.length... this lets me set the expand/contract properly without filling in the children first.
I've also created an HFolderTree (with matching HFolderTreeNode, etc.) to have a "directory browser", where a "leaf" is a folder with no sub-folders. This lets me always show folder icons, as most would expect.
Any tips would be appreciated.