Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stephen on Oct 06, 2009 07:04
open dhtmlx forum
dhtmlxTree drag-n-drop target id incorrect when it has no child nodes?

Maybe its my code thats wrong I don;t but in function tondrag(sid, tid, bid)
the tid appears to have an incorrect value when the tid has no child nodes

1. With child node: tid=/colour/yellow
======================
Tree
-----
colour
-red
--apple
-yellow
--lemon

moving apple to just below yellow results in

sid=/colour/red/apple
tid=/colour/yellow
bid=/colour/yellow/lemon

1. Without child node tid=/colour
========================
Tree
-----
colour
-red
--apple
-yellow

moving apple to just below yellow results in

sid=/colour/red/apple
tid=/colour <<<<<<<<<<<<< should this be as above tid=/colour/yellow
bid=null
Answer posted by Stanislav (support) on Oct 08, 2009 07:11
The tid points to the item under mouse only if default d-n-d mode is used.
In sibling and complex drag modes, it possible that mouse is not pointing to any item at all ( placed between items ) , so values of parameters need to be threated as

tid - id of target parent 
bid - id of target next sibling


sid=/colour/red/apple
tid=/colour/yellow
bid=/colour/yellow/lemon
drop as child of "/colour/yellow" before "/colour/yellow/lemon"

sid=/colour/red/apple
tid=/colour 
bid=null
drop as last chld of "/colour"

Answer posted by Stephen on Oct 12, 2009 11:45
I should have pointed out that I only want to allow d-n-d at same level therefore I am using complex drag mode

I can amend my code and treat the sid, tid, bid as suggested but how do I affect the dhtmlx tree drop?
Two egs d-n-d1 and d-n-d2 to illustrate:

Tree
-----
colour
-red
--apple
-yellow
<<<<<<<<<<<< d-n-d1 apple to here
-green
<<<<<<<<<<<< d-n-d2 apple to here

d-n-d1
-------
sid=/colour/red/apple
tid=/colour/
bid=/colour/green
drop as child of "/colour/yellow" before "/colour/green"

d-n-d2
-------
sid=/colour/red/apple
tid=/colour/
bid=null
drop as chld of last chld of "/colour"

Problem is dhtmlx - in both cases - drops the node apple as a child of /colour.
How do I change the dhtmlx tid? The tid in the dragHandler is passed in by value.

The handler appears to be called from
dhtmlXTreeObject.prototype._dragIn=function(htmlObject,shtmlObject,x,y){
where  var tobj=htmlObject.parentObject;