Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Zamefame on Nov 04, 2008 07:29
open dhtmlx forum
dhtmlx Tree dataprocessor

Hi,

I am using dhtmlx tree v2.0 with dataprocessor to insert tree in database. But while creating the tree after loading the web page, I cannot add a single initial node by using the functions. I get no error. This is the following part of code for adding/deleting I am trying:

<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxtree.css">
<script src="../../codebase/dhtmlxcommon.js">
</script><script src="../../codebase/dhtmlxtree.js">
</script><script src="../../codebase/ext/dhtmlxtree_ed.js">
</script><script src="../../codebase/dhtmlXDataProcessor.js" type="text/javascript">
</script>

<a href="#" onclick="var d=new Date(); tree.insertNewItem(tree.getSelectedItemId() || 0,d.valueOf(), 'New Item');>Add node as child of selected (or top)</a>

<a href="#" onclick="var d=new Date(); tree.insertNewNext(tree.getSelectedItemId(), d.valueOf(), 'New Item');>Add node next to selected</a>

<a href="#" onclick="tree.deleteItem(tree.getSelectedItemId(),true);">Delete selected row</a>


<script>
     var tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
tree.setImagePath("../../codebase/imgs/csh_winstyle/");
tree.enableDragAndDrop(true);
tree.enableItemEditor(true);
tree.loadXML("php/get.php");

var myDataProcessor = new dataProcessor("php/update.php");
        myDataProcessor.enableDebug(true);
myDataProcessor.init(tree);    
</script>


I have created the database table from sampleDB file. I even get valid xml data from get.php. Your help will be greatly appreciated. Thanks a lot.
Answer posted by Support on Nov 04, 2008 07:54
You have a typo in link code

<a href="#" onclick="var d=new Date(); tree.insertNewItem(tree.getSelectedItemId() || 0,d.valueOf(), 'New Item');">Add node as child of selected (or top)</a>

the closing quote was missed, and as result link was non-functional

Answer posted by zamefame on Nov 04, 2008 10:38
oops! sorry i actually did put the closing but forgot to put it here.Thanks for ur quick reply. Anyways I got something to work but partially. Here is my new code:

tree.insertNewItem(tree.getSelectedItemId() || 0,d.valueOf(), 'New Item',0,0,0,0,'SELECT')

var tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);             
               tree.setImagePath("../../codebase/imgs/csh_winstyle/");              
               tree.enableDragAndDrop(true);
               tree.enableItemEditor(true);                           
               tree.loadXML("php/get.php");                    
           
            myDataProcessor = new dataProcessor("php/update.php");
            myDataProcessor.enableDebug(true);          
            myDataProcessor.init(tree);   
            tree.init();

By this code when I add a node it inserts into database with a message but shows nothing on the web page. When I remove enableDebug(true) it does nothing.
Now when I place tree.init() before the loadXML function I can add nodes but does not insert anything into the database. I dont think there is any syntax error as I keep checking the error console of browser too. A help here would be great here now. Thanks.
   
Answer posted by Support on Nov 05, 2008 04:09
>> tree.init();
dhtmlxtree doesn't support such method as init , it is initialized automatically and need not any special command for it. 

>>By this code when I add a node it inserts into database with a message but shows nothing on the web page. When I remove enableDebug(true) it does nothing.
Exactly the same code works correctly in local sample. 
Please check working sample, which was sent by email. 
If issue still occurs for you - please provide exact HTML page where issue can be reconstructed ( you can send it directly to support@dhtmlx.com