tags:

views:

12

answers:

1

hi everyone

I want to validate a node before dropping it on tree. I used beforenodedrop event for this purpose but validation is occured on server side so as response does not come in time and function always return true so node is dropped. i want to know which method/event should be used for this purpose

Here is my code for beforenodedrop event

treeList_fnBeforeNodeDrop = function (e){     
    if(e.target.attributes.LocationLevel<=e.data.node.attributes.LocationLevel)//if node is dropped on node of previous level
    {
       return true;
    }else{ //If node is dropped on level greather than its level like region into area verify its hierarchy

        Ext.Ajax.request({
            method: 'POST',
            url: this.webService + '/ValidateNodeDrop',
            params: {DropLocationId: e.data.node.id,ParentLocationId:e.target.id, TargetLocationLevel:e.target.attributes.LocationLevel},
            success: function ( result, request ) {
                 return true;
            },
            failure: function ( result, request ) {
                Ext.Msg.alert('Failure', 'You can not drop node at this level');

                return false;
            }
        });

    }
}

Please help me what mistake i have done

+1  A: 

I propose your function always returns false (so it doesn't allow dropping the node), but when the ajax request returns the appropriate value (i.e. the server allows dropping), you drop the node programatically.

Other possibility: You generally allow it, but on failure, you undo the change.

ammoQ