2010-10-27 93 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