Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jame Chiang on Jun 10, 2009 23:38
open dhtmlx forum
wrong itemid after drop

           follow previous answer's instructions

http://dhtmlx.com/docs/products/kb/index.php?s=normal&q=9887&a=16002

my code: 

    dhxTree.attachEvent("onDrag",function(sid,tid){
   
    if(tid == sid) return false; /* denies same people*/   
    var list = this.getSubItems(tid);

    if (list.length == 0)
    {
        this.changeItemId(sid,tid+"_"+sid);/*sets new id*/    
        return true;
    }  
    else
    {
    leaves = list.split(",");
    for(var i =0; i < leaves.length;i++)
        if(leaves[i]==tid+"_"+sid) return false; /* denies drag-n-drop*/
        this.changeItemId(sid,tid+"_"+sid);/*sets new id*/
        return true;
    }
    })  


Source tree’s structure like this:
Level1:Area-A
Level2:  Customer-A(id:13-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: 13-11)
Level2:  Customer-C (id: 13-3)
Level1: Type-B
Level2:  Customer-B (id: 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, 6
Target tree’s structure like this:
/line1/Level1:Type-A
/line2/Level2:  Customer-A (id: 13-11)
/line3/Level3:    Customer-B (id: 13-1)
/line4/Level2:  Customer-C (id: 13-3)
/line5/Level1: Type-B
/line6/Level2:  Customer-B (id: 13-11_13-1)


3. drag “Customer-B”, drop “Customer-C”, add in, wrong item-id at line3, 5, 7
Target tree’s structure like this:
/line1/Level1:Type-A
/line2/Level2:  Customer-A (id: 13-11)
/line3/Level3:    Customer-B (id: 13-3_13-1)
/line4/Level2:  Customer-C (id: 13-3)
/line5/Level3:    Customer-B (id: 13-1)
/line6/Level1: Type-B
/line7/Level2:  Customer-B (id: 13-11_13-1)

seems index have some problems !!

using dhtmlxTree v.2.0 Professional edition build 81009/81107

Answer posted by Alex (support) on Jun 11, 2009 01:53