wrong itemid after drop (part 2)


follow previous instructions, change my code and tree ids:



dhtmlx.com/docs/products/kb/inde … 03&a=16028



my code:



    dhxTree.attachEvent(“onDrag”,function(sid,tid){
   
    if(tid == “t_”+sid) return false; /* denies same people*/   
    var list = this.getSubItems(tid);
    var tid_t = tid.substr(2,tid.length-2);
   
    if (list.length == 0)
    {
        this.changeItemId(sid,tid_t+""+sid);/sets new id/    
        return true;
    }  
    else
    {
    leaves = list.split(",");
    for(var i =0; i < leaves.length;i++)
        if(leaves[i]==tid_t+"
"+sid) return false; /* denies drag-n-drop*/
        this.changeItemId(sid,tid_t+"_"+sid);/sets new id/
        return true;
    }
    })  
 



Source tree�s structure like this:
Level1:Area-A
Level2:  Customer-A(id:t13-11)
Level2:  Customer-B(id:13-1)
Level1:Area-B
Level2:  Customer-C(id:13-3)



Target tree�s structure like this:
Level1:Type-A
Level2:  Customer-A (id: t_13-11)
Level2:  Customer-C (id: t_13-3)
Level1: Type-B
Level2:  Customer-B (id: t_13-1)



1. drag �Customer-A�, drop �Customer-A�, action cancel, ok



2. drag �Customer-B�, drop �Customer-A�, add in, wrong item-id at line3 
Target tree�s structure like this:
/line1/Level1:Type-A
/line2/Level2:  Customer-A (id: t_13-11)
/line3/Level3:    Customer-B (id: 13-1, id no change)
/line4/Level2:  Customer-C (id: t_13-3)
/line5/Level1: Type-B
/line6/Level2:  Customer-B (id: t_13-1)



3. drag �Customer-C�, drop �Customer-A�, add in, wrong item-id at line3,4
Target tree�s structure like this:
/line1/Level1:Type-A
/line2/Level2:  Customer-A (id: t_13-11)
/line3/Level3:    Customer-B (id: 13-1, id no change)
/line4/Level3:    Customer-C (id: 13-3, id no change)
/line5/Level2:  Customer-C (id: t_13-3)
/line6/Level1: Type-B
/line7/Level2:  Customer-B (id: t_13-1)



4. drag �Customer-B� again, drop �Customer-A�, add in, wrong item-id at line4,5



Target tree�s structure like this:
/line1/Level1:Type-A
/line2/Level2:  Customer-A (id: t_13-11)
/line3/Level3:    Customer-B (id: 13-11_13-1, correct, but is second times )
/line4/Level3:    Customer-C (id: 13-3, id no change)
/line5/Level3:    Customer-B (id: 13-1, id no change)
/line6/Level2:  Customer-C (id: t_13-3)
/line7/Level1: Type-B
/line8/Level2:  Customer-B (id: t_13-1)



 


Sorry for the misleading information. The id should be changed when item is dropped (when onDrop is called):


dhxTree.attachEvent(“onDrag”,function(sid,tid){
if(tid == sid) return false; /* denies same people*/
var list = this.getSubItems(tid);
leaves = list.split(",");
for(var i =0; i < leaves.length;i++)
if(leaves[i]==tid+""+sid) return false; /* denies drag-n-drop*/
return true;
})
dhxTree.attachEvent(“onDrop”,function(sid,tid){
this.changeItemId(sid,tid+"
"+sid);/sets new id/
return true;
})