Automatic sorting in tree?

Dear DHTMLX experts,

I have dhtmlxTree pro and have a tree with just one parent node and many child nodes. DragAndDropBehavior is “sibling”, and I can drop items from other trees just fine.

However, this tree has to be sorted alphabetically, so I need an “autosort” functionality so that no matter where an item is dropped, it will be moved to the correct position automatically. I tried using the “sortTree” method, but this always gives me a javascript error “Object does not support this property or method”.

This is my code:


The same error happens when I use the example code from the "Smart XML parsing and Sorting
" example in the documentation:

#tree_var#.attachEvent("onDrop",function(id, target, target_before, tree_source, tree_dest){tree_dest.sortTree(target,'ASC',1);});

What am I doing wrong? Is there another way to achieve the desired autosort functionality?

Regards, Richard

This method needs dhtmlxtree_sb.js extention. Have you included it?

Thanks. I must have been blindfolded when reading the documentation :blush: