Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by David on Feb 06, 2009 09:26
open dhtmlx forum
Tree: Inline XML and onClick event

Do have as much control over appearence and events using inline XML as I would if load XML from a file? I am having a problem getting the onClick event to work with inline XML, and I don't think my script below to create the tree object and specify the onClick event handler is working. Here's my code. What is wrong with it?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>Test Investor Reports page</title>
</head>

<body >
<link rel='STYLESHEET' type='text/css' href='/common/style.css'>
<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_start.js"></script>

    <script>
    
            function tonclick(id){
                alert("hello");
            };

    </script>


    <table>
        <tr>

            <td>

    
    <div id="treeboxbox_tree2" setImagePath="../codebase/imgs/" class="dhtmlxTree">
        <xmp>
        
                <item text="Account Statements" select="1" open="1" id="2" im0="folderClosed.gif">
                    <item text="January 2008" id="3"/>
                    <item text="February 2008" id="4"/>
                </item>
                
                <item text="Tax Documents" select="1" open="1" id="7" im0="folderClosed.gif">
                    <item text="2007 Form K-1" id="8"/>
                    <item text="2008 Form K-1" id="9"/>
                </item>
                
                <item text="Quarterly Reports" select="1" open="1" id="10" im0="folderClosed.gif">
                    <item text="Q3 2008 Report.pdf" id="11"/>
                </item>
                
                <item text="Audited Financial Statements" select="1" open="1" id="12" im0="folderClosed.gif">
                </item>
                
                <item text="Offering Documents" select="1" open="1" id="13" im0="folderClosed.gif">
                </item>
                
                <item text="Other Documents" select="1" open="1" id="14" im0="folderClosed.gif">
                </item>
                
            
        </xmp>
    </div>
    
    
            </td>
        </tr>
    </table>
    
    <script>
            tree=new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0);
            tree.setOnClickHandler(tonclick);
    </script>

</body>
</html>
Answer posted by Support on Feb 06, 2009 10:07
a) remove  class="dhtmlxTree" to prevent double initialization
b) replace  
      tree=new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0);
with
      tree=new dhtmlXTreeFromHTML("treeboxbox_tree2");
Answer posted by Andrew on Jul 19, 2009 21:26
You might like to update the documentation on inline XML. I have had the same frustrating problem until finally finding this post.
Answer posted by Alex (support) on Jul 20, 2009 03:16