Hello, I have 2 problems on the DHTMLXTree.
1. Could you please tell me how to check if the user is dragging in sibling mode?
I want to do something while user is dragging a node in sibling mode, so I use onDragIn event, but can you tell me how to check if the user is dragging in sibling mode?
2. Could you please tell me how to only open the level 3 nodes after the tree is initialed?
I have a lot of levels in my tree, I need it only open the level 3 nodes and all nodes under level 3 is closed after the tree is initialed.
Waiting for your reply.
Thanks very much.
Hello,
do you complex drag mode ?
If you do, try to use the following approach:
tree.attachEvent(“onDragIn”,function(sid,tid){
window.setTimeout(function(){
if(tree.selectionBar.style.display!=“none”) {/your code for sibling drag/}
},1)
return true
})
To open a certain number of levels you can use getSubItems method to get child items from the next level. You can iterate through necessary items by this method. The openItem method can be used for opening
Hi, Alex
Thanks very much for your kind reply.
Your code is very helpfull, but I still complete the need from the client, could you give me some advise?
We have a tree like this:
|- Root
|- Folder_Level1_1
|- Folder_Level2_1
|- Node_1
|- Node_2
|- Folder_Level2_2
|- Folder_Level1_2
|- Folder_Level2_3
|- Node_3
|- Node_4
|- Folder_Level2_3
The need is :
1. Folders and nodes in the same level can drag in sibling mode to change the order
2. Nodes can not drag into each other.
For example, Node_1 can not be dragged to Node_2 as its child node, Node_1 can not be dragged into Node_3 as its child node.
3. Nodes can only be dragged into Folder_level2.
4. Folder_level2 can only be dragged into Folder_level1.
My problem point is how to limit the nodes can be dragged into upper level, can be ordered, but can not be dragged into other nodes in complex drag mode.
Thanks in advance.
Hello,
the onDrag event allows to block dropping. The drag-n-drop is denied if onDrag event doesn’t return true. The event gets source and target item ids as arguments.
You can use getLevel method for check target item level:
tree.attachEvent(“onDrag”,function(sid,tid){
return (this.getLevel(tid)<3);
})
Hi, Alex
Thanks for your kind reply.
But if I use your codes:
tree.attachEvent(“onDrag”,function(sid,tid){
return (this.getLevel(tid)<3);
})
Nodes in level 3 can not be dragged in sibling mode.
But I need it can be dragged to order.
Is there any other idea? Thanks in advance.
Hello,
possibly the level should less than 4:
return (this.getLevel(tid)<4);
tid always returns parent item id.