2010-10-27 97 views
0

我想验证一个节点,然后将它放到树上。 为此目的,我使用beforenodedrop事件,但在服务器端发生验证,以便响应没有及时到达,并且函数始终返回true,因此节点被丢弃。我想知道哪些方法/应该被用于此目的取消节点丢弃

这里事件是我beforenodedrop事件代码

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; 
      } 
     }); 

    } 
} 

请帮我什么错误,我已经做了

回答

1

我建议你的函数总是返回false(所以它不允许删除节点),但是当ajax请求返回适当的值(即服务器允许丢弃)时,可以以编程方式删除节点。

其他可能性:您通常允许它,但如果失败,则撤消更改。

+0

当我不是一个单一的节点,但它具有层次结构即节点和它的孩子 – Saima 2010-11-06 04:53:53

+0

你的第二个建议我如何删除节点:我试试这也是失败我删除添加的节点,但我不能添加节点到它以前的位置,bcs它包含层次可以给我示例代码 – Saima 2010-11-06 04:55:04