DHTMLX Docs & Samples Explorer

Index
dhtmlxconnector
Usage Guide

### Multi-table tree and treegrid

In many cases, tree or treegrid need to be built from multiple tables. Each table represent separate level of tree or treegrid. For tree it can be done as

    	require("../../codebase/treemultitable_connector.php");

    	$tree = new TreeMultitableConnector($res);
    	$tree->setMaxLevel(3);
    	$level = $tree->get_level();

    	switch ($level) {
    		case 0:
    			$tree->render_table("projects2","project_id","project_name","","");
    			break;
    		case 1:
    			$tree->render_sql("SELECT teams2.team_id, teams2.team_name, project_team2.project_id FROM teams2 INNER JOIN project_team2 ON teams2.team_id=project_team2.team_id", "team_id", "team_name", "", "project_id");
    			break;
    		case 2:
    			$tree->render_table("developers2", "developer_id", "developer_name", "", "developer_team");
    			break;
    		case 3:
    			$tree->render_table("phones2", "phone_id", "phone", "", "phone_developer");
    			break;
    	}

Multi-table connector will work only for tree|treegrid with dyn. loading mode enabled

Similar code can be used for treegrid , the only difference in the connector class

    	require("../../codebase/treegridmultitable_connector.php");

    	$treegrid = new TreeGridMultitableConnector($res);
    	$treegrid->setMaxLevel(3);
    	$level = $treegrid->get_level();

            ...