Topic: Toggle Tree Features

Hey there
I've got a problem with the initialisation of advanced features like Sortable.
Is it a Must to initialize and activate these features on Tree initialisation?
There is a request for an application I am working on at the moment to toggle the Sortable function of the tree.
Per default sorting shold be off, users can click a button to turn sorting on and off again.
Is it possible to initiate sorting after the tree has been built?
Or - if not - is it possible to disable the initiated sorting functions to enable it later?

Regards, Michael

Re: Toggle Tree Features

you can change Mif.Tree.Node::sort

sort: function(sortFunction){
    if(this.tree.sortable) this.children.sort(sortFunction||this.tree.sortFunction);
    return this;
}

and after set tree.sortable=true/false

Re: Toggle Tree Features

Thank you.
This works wink

Do you also know a solution to toggle Drag?

Re: Toggle Tree Features

If anyone else needs it, I built this solution to toggle dragable:

            Mif.Tree.SCMDrag = new Class({
                Extends: Mif.Tree.Drag, 
                start: function(event){
                    if(this.tree.options.dragable)
                        this.parent(event);
                }
            });

So on initialisation of the tree you have to use this:

            var instance = new Mif.Tree({
                initialize: function(){
                                    new Mif.Tree.SCMDrag( this, {preventDefault: true});
                    ...
                }, 
                    ...
                dragable: false
            }); 

... and can turn dragable on and off by calling:

instance.options.dragable = true; //On
instance.options.dragable = false; //Off

Re: Toggle Tree Features

tree.drag.detach();
tree.drag.attach();