PDA

View Full Version : How to cancel a drop event after receive a server response



sdo
6 Jul 2009, 1:41 AM
How to cancel a drop event?The code:


tree.on('beforemovenode',function(tree,node,oldP,newP,index){
var succ;
var i=Ext.Ajax.request({
url:'system/ddMenu.php' (http://extjs.com/forum/'system/ddMenu.php'),
params:{
nodeId:node.id,
oldFatherId:oldP.id,
newFatherId:newP.id,
dropIndex:index
},
callback:function(options,success,resp){
succ=Ext.decode(resp.responseText).success;
}
});
return succ });

but the callback is invoked after return succ.If i want to return a value succ which is getted from server,what should i do?Thanks.

Animal
6 Jul 2009, 2:09 AM
You have to veto the drop in the http://extjs.com/deploy/dev/docs/?class=Ext.tree.TreePanel&member=beforenodedrop event.

Then programatically move the node in the Ajax success handler.

sdo
6 Jul 2009, 4:24 PM
tree.on('beforemovenode',function(tree,node,oldP,newP,index){
var succ;
var i=Ext.Ajax.request({
url:'system/ddMenu.php' (http://extjs.com/forum/'system/ddMenu.php'),
params:{
nodeId:node.id,
oldFatherId:oldP.id,
newFatherId:newP.id,
dropIndex:index
},
callback:function(options,success,resp){
var result=Ext.decode(resp.responseText);
if(result.success){
node=oldP.removeChild(node);
newP.appendChild(node);
}else{
alert(result.info);
}
}
});
return false;
});

Thanks ,man.
I have changed the code.But after remove the node,it can't add the node successfully.
Why?

Animal
6 Jul 2009, 9:28 PM
Dunno. Debug it.

extjs_new
3 Jan 2010, 10:54 AM
hi sdo,

I need to know also how did you solve this issue of yours?
I need to cancel also onBeforeNodeDrop when my Ajax returns unsuccessful messages..