Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by rassol on Jul 04, 2008 01:55
open dhtmlx forum
From Html to drag-n-drop.

Hello!
First of all, thank you for your job - it's a brilliant script.
Know I'm trying to use it and have a question: i'm initializing tree from HTML list. It all works fine. But I need drag'n'drop feature.
Standart construction from docs doesn't work for me.
This is my code:
----------------------
<div id="listBox" setImagePath="imgs/" style="width:250px; height:218px; background-color:#f5f5f5;border :1px solid Silver;">
    <ul>
        <li id="node1">Root
        <ul>

            <li id="node2">Child1
            <ul>
                <li id="node2">Child 1-1</li>
            </ul>
            </li>
            <li id="node4">Child2</li>
            <li id="node3"><b>Bold</b> <i>Italic</i></li>

        </ul>
        </li>
    </ul>
</div>
<script>
var myTree = dhtmlXTreeFromHTML('listBox');
myTree.enableDragAndDrop(1);
myTree.setDragHandler(myDragHandler);
function myDragHandler(idFrom,idTo){
//if we return false then drag&drop be aborted
return true;
}
</script>
------------------

Thу question is what I'm doing wrong?
Answer posted by rassol on Jul 04, 2008 02:50
ok, I've made it myself by changing initialization of tree in dhtmlxtree_start.js
I've initialized drag'n'drop after declaration of object and know it works fine.
thz to all dev.team one more time ;)
Answer posted by Jan Müller on Jul 10, 2008 02:16
Hi,

just trying to get used to the skript but same for me, no d&d in HTML build tree.
so would be nice to know how you 'fixed' it.

in dhtmlxtree_start.js the object is initialized as t. but t.enableDragandDrop is not known there, so how did you do it?

Thx Jan

Answer posted on Jul 10, 2008 03:16

Ok, if you want to use d'n'd in html-initialized tree, you must edit file dhtmlxtree_start.js.

Just find code var t=new dhtmlXTreeObject(obj,"100%","100%",0); and  add after it that string: t.enableDragAndDrop(1);

Answer posted by Support on Jul 10, 2008 03:34
If you init tree from HTML container you can add next attribute to it
    <div id="treeboxbox_tree" setImagePath="../../codebase/imgs/csh_bluebooks/" class="dhtmlxTree" enableDragAndDrop="true"

All attributes which starts from set or enable will trigger related js commands during tree initialization
Answer posted by Jan Müller on Jul 10, 2008 04:06
Thx a lot

i used the attribute way, works fine.

Great job, Jan