Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by LV on Sep 07, 2009 05:36
open dhtmlx forum
Drag & drop - restricted drop

Hi,
I have a question about D&D.
I have an dhtmlxGrid displaying tree. I want to restrict the drop by not allowing to drop element to the root level. (There can be only one tree with one root, but the leaves can move).
I'm using complex behaviour.
grid.enableDragAndDrop(true);
grid.setDragBehavior("complex");
The problem is that in onDragIn event I can not decide how the tree will look like. I can do this in onDrop event by this way:
function grid_onDrop(sid,tid,did) {
var targetParent = grid.getParentId(did);
if (targetParent == 0) {
doNotAllow();
}
...

But this is not very nice..



Answer posted by dhxSupport on Sep 07, 2009 06:43
Please find complete documentation about managing drag-n-drop here http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxgrid:toc_managed_drag_and_drop
Answer posted by LV on Sep 08, 2009 00:45

Hi.

I've read the documentation, but still I have no clue, how to implement this.

I've tried this:

I have a tree:

1

  2

    3

  4

function grid_onDragIn(sid,tid) {
        var canDrop = grid.getLevel(tid) !=0;
        return true;
    }

I want to forbid trees like:

1

  2

3

  4

 

The probles is that with dragging rowId 3 to put it to the level 0, I get rowId (1) sid = 3, tid = 1 and when I'm dragging 3 to to put to under (1) to level 1 I get the same sid = 3, tid = 1 and tree looks like

1

  2

  4

  3

 

The problem is that when dragging in "complex" D&D scenario, I can not decide if user wants to place dragged node under tid or next to tid. Is there a way how to distinguish these?