Can't access any method of dhtmlxtree

I am unable to access any method of dhtmlxtree.
I have created a div element named “treebox” and then in the script I have written as follows:

        var tree = new dhtmlXTreeObject("treebox","100%","100%",0);
        var checkState = tree.isItemChecked(tree.getParentId());
        var parentId= tree.getParentId();

But neither I am able to get any parentId nor to enable the checkbox, although the tree is appearing fine and double-click is working fine.
Checkbox is not appearing.

Please help me out.

getParentId is purposed to get the id of parent item in the tree, it must receive id of item as parameter

var pid = tree.getParentId(id)

Calling it without parameters, as in your case, has not sense.
Also, be sure that tree already have data ( the above code snippet doesn’t show how data was loaded in the tree )

I have imported dhtmlxtree.css,dhtlxtree.js,dhtmlxcommon.js,dhtmlxtree_start.js files
the tree div data is as follows:

  • Root
    • Child1
      • Child 1-1
    • Child2
    • Bold Italic

But still the enableCheckBoxes(true) method is not showing the checkboxes?

to add to my previous post…

If i call the method tree.getAllItemsWithKids() , it is not returning anything… I am using Firefox 12.0.

Move enableCheckboxes command to the html tag like next

and replace in your js code

var tree = new dhtmlXTreeObject("treebox","100%","100%",0);


var tree = dhtmlXTreeFromHTML("treebox");

thanx Stanislav .

It’s Working Fine Now…
I hv a question.
Instead of doing HTML based initialization, if I want to do object based initialization what will be my correct approach?

The original code ( in first post ) is correct, you just need to use an empty div for “treebox”, and add one more line which will load tree data in the component ( from xml, or json ) … ta_loading