DHTMLX Tree not loading PHP file in Version 4.0

Hi DHX Team,
Kindly look at the following code, I’ve written for rendering a tree from the database.
/////////////////Table Creation Script//////////////////
CREATE TABLE module_mstr (
mod_code int(3) NOT NULL COMMENT ‘Module Identifier Code’,
mod_title varchar(100) NOT NULL,
mod_file varchar(64) DEFAULT NULL,
mod_parent int(3) DEFAULT ‘0’ COMMENT ‘Parent Module (Module Herarchy)’,
PRIMARY KEY (mod_code),
KEY fk_mod_hier (mod_parent),
CONSTRAINT fk_mod_hier FOREIGN KEY (mod_parent) REFERENCES module_mstr (mod_code)
The Server side PHP File: module_tree.php
(This runs fine when I execute it in the browser)

<?php require("connectors/tree_connector.php"); $conn = mysql_connect("localhost","root","lqsym"); mysql_select_db("busappdb"); $mytree=new Treeconnector($conn); $mytree->render_table("module_mstr","mod_code","mod_title","","mod_parent"); ?>

The HTML File (This is the problem I’m unable to figure out

//////////////////////////////////////////////////////// The output of the PHP file is given below: when I use http:// localhost/module_tree.php?id=1 /////////////////////////////////////////////////////// This XML file does not appear to have any style information associated with it. The document tree is shown below. ////////////////////////////////////////////////////////// However in the execution of the HTML, I don't get any output Kindly help out a priority basis.


Hi Manish,

There are different root ids defined for Tree and its datasource.

Tree has 0 as root id (the forth parameter of dhtmlxTreeObject constructor):

mytree = new dhtmlxTreeObject(“mytree”,“100%”,“100%”,0);

and datasource contains data for the “1” root:

If you change root id in tree definition to “1”, the data will be loaded correctly:

mytree = new dhtmlxTreeObject(“mytree”,“100%”,“100%”,“1”);

Hi Alexandra,
I have even done that. Also it works with id=0. The problem is on either the client side code, or with version 4.0.2 that I’m using. Kindly help out on a priority basis.
The PHP Output
This XML file does not appear to have any style information associated with it. The document tree is shown below.



The client side code for your perusal is given below:
//////////////HTML FILE////////////////////////

I get the following error in the IE developer tools console debugger. This shows that there’s an error in the connector.js file on line 148. please see the attached image and help me out.

Also for your convenience see the client side code I’ve written.

//////////////////////////////////////////////////////// Regards Manish

After making minor changes, I still get the error as shown. Overall the situation is such that the error is shown in the connector.js file.

Can anyone at DHTMLX please answer my query? Alexandra, Stanislav, … please help out.
We’re evaluating DHX against JQUERY UI and Ext JS. I have pitched in strongly in favor of DHX.

We’ve almost completed building sample application using the other two. With DHX it’s stuck up for the tree widget and binding form and grid. Please help out, so that my team can put up an evaluation application fast and help management arrive at a purchasing decision in DHX favor.


Hello Manish,

the error is shown in the connector.js file.

connector.js should be included after dhtmlx.js

Also there is the problem in the js code snippet with tree init.

You are using
mytree = new dhtmlxTreeObject({“mytree”,“100%”,“100%”,0)};

that is incorrect js statement. There should be the following

mytree = new dhtmlxTreeObject(“mytree”,“100%”,“100%”,0);

Hi Alexandra,
Made the suggested changes but still not working. Kindly examine my code as given below and suggest:


Also, I get the following errors in the Mozilla Browser Console:

TypeError: this.parentObject is null dhtmlx.js:1613

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. module_tree.html

I never got his error before when I successfully rendered a tree.

Both the screenshots from IE Console and Mozilla Console are pasted side by side for help in debugging. Kindly have a look and help. This error persists even when I’m using version 3.6.


Your code initializes the tree in non-existent html container - dhtmlxTreeObject is called before a page with “mytree” div is loaded. Here is example of the correct code:



I have used the code you’ve given and run the same from the browser after checking the code.
It still doesn’t work. Please see the screen shot I’ve attached.


please attach a demo where we could reproduce the problem:
docs.dhtmlx.com/auxiliary_docs__ … pport.html

Please find the code files attached in the zip file. It contains both the server side and client side code. Server side works well. The table script is also attached for your convenience.

problem code.zip (1.63 KB)


we have corrected the demo (check comments in code)
problem code.zip (289 KB)

Yes, it’s working only when I use the dhtmlx.js and dhtmlx.css files you’ve sent. I’ll use the same codebase for my other application components. Thanks much Alexandra.