<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Mifjs forum — Mif.Tree, Mif.Menu - Tree: sort after drag]]></title>
	<link rel="self" href="http://www.mifjs.net/forum/feed/atom/topic/218/"/>
	<updated>2010-07-02T11:20:00Z</updated>
	<generator>PunBB</generator>
	<id>http://mifjs.net/forum/topic/218/</id>
		<entry>
			<title type="html"><![CDATA[Re: Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/809/#p809"/>
			<content type="html"><![CDATA[Thx for your help,
I really appreciate it :)]]></content>
			<author>
				<name><![CDATA[mrgroovy]]></name>
				<uri>http://mifjs.net/forum/user/144/</uri>
			</author>
			<updated>2010-07-02T11:20:00Z</updated>
			<id>http://mifjs.net/forum/post/809/#p809</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/808/#p808"/>
			<content type="html"><![CDATA[to disable node drag set node.dragDisabled = true]]></content>
			<author>
				<name><![CDATA[moro]]></name>
				<email><![CDATA[creavenmoro@gmail.com]]></email>
				<uri>http://mifjs.net/forum/user/2/</uri>
			</author>
			<updated>2010-07-01T10:07:55Z</updated>
			<id>http://mifjs.net/forum/post/808/#p808</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/807/#p807"/>
			<content type="html"><![CDATA[Absolutely awesome!, thx man :D
should make this a feature ;)

I have another question:
Sometimes i want to cancel a drag action.

I should explain my situation:
Nodes in the tree represent site content,
when a node is selected the content of that node will be displayed in a form.
So when the user edits the form and clicks on another node i display a overlay
with a message like "There are unsaved changes, save YES / NO".

The overlay will show on mousedown (the select event).
And if the user keeps the mouse button down and moves the mouse he will drag the node
behind the overlay.

So my question is:
Is it possible to cancel the current drag action ?

Tried this:

[code]
onDrag: function(){
    if(dragIsDisabled)
    {
        this.where = 'notAllowed';
        this.emptydrop();
        return;
    }
}
[/code]]]></content>
			<author>
				<name><![CDATA[mrgroovy]]></name>
				<uri>http://mifjs.net/forum/user/144/</uri>
			</author>
			<updated>2010-06-30T20:56:55Z</updated>
			<id>http://mifjs.net/forum/post/807/#p807</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/806/#p806"/>
			<content type="html"><![CDATA[it don't work if sorted childrens have subchildrens, you can try this:
[code]
var parent = this.current.getParent();
parent.sort(function(node1, node2){
    if(node1.name>node2.name){
        return 1;
    }else if(node1.name<node2.name){
        return -1;
    }else{
        return 0;
    }
});
var childrenEl = parent.getDOM('children');
for(var i = 0, l = parent.children.length; i < l; i++){
    parent.children[i].getDOM('node').inject(childrenEl);
    Mif.Tree.Draw.update(parent.children[i]);
}
parent.tree.$getIndex();
this.current.tree.scrollTo(this.current);
[/code]
for tree (not forest)]]></content>
			<author>
				<name><![CDATA[moro]]></name>
				<email><![CDATA[creavenmoro@gmail.com]]></email>
				<uri>http://mifjs.net/forum/user/2/</uri>
			</author>
			<updated>2010-06-29T21:54:21Z</updated>
			<id>http://mifjs.net/forum/post/806/#p806</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/805/#p805"/>
			<content type="html"><![CDATA[Thx for the respone!

Will try this out tomorrow,
now i need to sleep :)]]></content>
			<author>
				<name><![CDATA[mrgroovy]]></name>
				<uri>http://mifjs.net/forum/user/144/</uri>
			</author>
			<updated>2010-06-29T21:29:12Z</updated>
			<id>http://mifjs.net/forum/post/805/#p805</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/804/#p804"/>
			<content type="html"><![CDATA[yes this don't work, sort really don't sort nodes :-). It used internally with sortable tree, when all nodes sorted.

You can try this:
[code]
Mif.Tree.Node.implement({
    
    redraw: function() {
        this.$draw = false;
        this.tree.$getIndex();
        this.getDOM('children').innerHTML = '';
        Mif.Tree.Draw.update(this);
        return this;
    }       

});


this.current.getParent().sort(function(node1, node2){
    if(node1.name > node2.name){
        return 1;
    }else if(node1.name < node2.name){
        return -1;
    }else{
        return 0;
    }
});
this.current.getParent().redraw();
[/code]

and onDrop event or it'll use old parent]]></content>
			<author>
				<name><![CDATA[moro]]></name>
				<email><![CDATA[creavenmoro@gmail.com]]></email>
				<uri>http://mifjs.net/forum/user/2/</uri>
			</author>
			<updated>2010-06-29T21:17:59Z</updated>
			<id>http://mifjs.net/forum/post/804/#p804</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Tree: sort after drag]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/803/#p803"/>
			<content type="html"><![CDATA[Hello, first of all: the plugin is awesome, really like it alot.

My question: how to use sorting in combination with drag and drop.

tried something like this:
[code]
onComplete: function(){
    this.current.getParent().sort();
}
[/code]
Please help !
Thx]]></content>
			<author>
				<name><![CDATA[mrgroovy]]></name>
				<uri>http://mifjs.net/forum/user/144/</uri>
			</author>
			<updated>2010-06-28T19:38:41Z</updated>
			<id>http://mifjs.net/forum/post/803/#p803</id>
		</entry>
</feed>

