Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Max Gano on May 21, 2009 17:17
open dhtmlx forum
dhtxmlTree and connector : XML reffers to not existing parent

OK, been evaluating for five days straight 16 hrs/day, down to last major issue, my eyes are bleeding and I am getting a bit stupid, I fear.

I need help getting xmlTree attached to a layout cell working properly against a connector and MySql table.

I can load an xml file successfully, but I get the "XML reffers to not existing parent" exception when I try to activate the connector.

Here is the code from a simple teat from the top (or bottom, rather:

-- Table structure for table `testtree`
--

CREATE TABLE `testtree` (
`id` int(11) NOT NULL,
`id_parent` int(11) NOT NULL,
`name` varchar(2000) collate latin1_general_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

-- Dumping data for table `testtree`
--

INSERT INTO `testtree` VALUES(1, 0, 'First Child 0-1');
INSERT INTO `testtree` VALUES(2, 0, 'Second Child 0-2');
INSERT INTO `testtree` VALUES(3, 0, 'Third Child 0-3');


-- Connector
--

<?php
    require_once("../../../codebase/dhtmlx/ext_connector/grid_connector.php");
    require_once("../../../conf/db_conf.php");

    $res = mysql_pconnect($dbhost, $dbuser, $dbpwd);
    mysql_select_db ($dbname);

    $grid = new GridConnector($res);
    $grid->dynamic_loading(100);

    // modify this line only to match the data table info
    // parameter 1: name of table
    // parameter 2: name of column to use for row id in xml output
    // parameter 3: names of columns to display in grid control
    // parameter 4: name of column to user for parent row id
    $grid->render_table("samples_tree","item_id","item_nm","item_parent_id");
?>


-- code to attach and init tree
--

var treeGridTree = treeGridComboLayout.cells("b").attachTree(0);
        //treeGridTree.loadXML(pathstring + "ControlsView.xml");
        treeGridTree.loadXML(pathstring + "connector.php");

        //var dptree = new dataProcessor(pathstring + "connector.php");
        //dptree.init(treeGridTree);

(Note that I have commented out all steps after the loadXML step to isolate the problem. Also, the ControlsView.xml file loads successfully.)

So I know I am doing something silly. Much appreciate any guidance on what, exactly, that it.

Thanks,
Max

Answer posted by Support on May 22, 2009 03:13
a)You have
CREATE TABLE `testtree` ( 
but later you are using
$grid->render_table("samples_tree"

b) to work with tree , you need to use TreeConnector 
require_once("../../../codebase/dhtmlx/ext_connector/tree_connector.php"); 
...
$tree = new TreeConnector($res); 
...
$tree->render_table("testtree","id","name","id_parent"); 

>> treeGridTree = treeGridComboLayout.cells("b").attachTree(0); 
Not quite sure, but if you mean TreeGrid ( not the tree ) - init code must be different.
Answer posted by Max Gano on May 22, 2009 08:54

Got it, it's working, and I got a reasonably good night sleep so my fingers are now just fat, not weary.

Great stuff, and thanks for such a quick turn-around.

Max

Answer posted by Max Gano on May 22, 2009 09:06

OK, this seems to be solid now. I will start testing the functionality.

Just and FYI - the things I was missing were:

a) the tree_connector.php piece. The only example I had was for the grid_connector version. I assumed a connector was universal (silly of me) but it was an easy thing to miss

b) the "0" param setting for the attachTree() command. I know about that from the standard constructor method, but he documentation was unclear on whether that was an option for the attach version. I had actually tried both, and this snippet just happened to be a version where I had removed it just in case.

So, the request would be for some clear sample code for the tree (treeGrid) application if it is not available, and for an easy way to search for it if it is. The knowledgebase forum is pretty hit or miss.

Otherwise, your products rock. My recommendation is that we commit to you as our controls vendor. Obviously price isn't a major issue, so this recommendation is based on your obvious commitement to great product and to your quick, successefu and professional turn-around on both of the two issues I have run into. Great work.

Max

 

Answer posted by Support on May 22, 2009 09:59
>>The only example I had was for the grid_connector version.
Actually the connector package contains samples/tree folder which holds 6 samples of TreeConnector usage, but documentation really not so good ( it is already updated for 1.0 release, with separate topics for each component ) 

>>b) the "0" param setting for the attachTree() command
Thanks for your remark, we will update related article in documentation. 

>>The knowledgebase forum is pretty hit or miss.
Yep, in nearest month we plan to release extended documentation with search functionality - it may help to prevent similar problems in future.