Topic: Mif.Tree drag/drop: how to check of drag/drop for node is "allowed"

Hi,

Let me start with saying I really dig Mif.Tree smile I haven't had a chance yet to fully explore it, however I like it so far.

I have a question what is the appropriate way to check for an "allowable" drag/drop.
Say I want to use Mif.Tree for a page structure representation (e.g. in a site map or navigation).
Ideal would be that we could set rules like:
- Allow drag/drop in node X for all it's sub nodes
- Allow drag/drop in node groups W, X and Z

I understand this is a bit much to ask smile My current case is that I have a root with several nodes (main pages) and some have sub nodes (sub pages). I would to activate drag/drop in these sub nodes for setting a sort order.

I have a check now like this to make this work, however, I wonder if this is "OK"... any advice/ideas/tips..?

onDrag: function() {
    if(this.target && (
        this.target.getParent().isRoot() || 
        (this.target.getParent() != this.current.getParent()) || 
        (this.target.getParent() == this.current.getParent() && this.where == 'inside')
    )) {
        this.where = 'notAllowed';
    }
}

It feels a bit "hacked", even though for my situation it works. I was wonder if I could add more controls/rules regarding drag/drop in some sort of config setting perhaps...

Re: Mif.Tree drag/drop: how to check of drag/drop for node is "allowed"

in config you can only set dragDisabled and dropDenied properties. In other situations use onDrag event and change this.where. It's ok.

Re: Mif.Tree drag/drop: how to check of drag/drop for node is "allowed"

Ah, ok, thanks for confirming.

One more question though! I added a if(target.isRoot()) return; in the onDrop event to prevent dropping on the root, forgetting about the dropDenied property. So I added a dropDenied=true to the root and noticed it didn't automatically expand my tree anymore (using a recursive on this.root and this.toggle). Is this standard behaviour or perhaps a "bug".

Nothing serious though, just didn't see it in the docs if it's default behavious or not (no time to check the source yet).

Cheers

Re: Mif.Tree drag/drop: how to check of drag/drop for node is "allowed"

should be dropDenied=['before', 'after'] and it's default property for root node.