The default connector for Tree and TreeGrid expects that data in DB is stored with child-parent key relation. But in some cases, Tree or TreeGrid need to be shown from plain data (by grouping it). Such a task can be resolved with help of the TreeGroupConnector or TreeGridGroupConnector.
For example, a table 'products' is grouped by category. As a result, the top level is 'categories', the second level - 'products', related to the category.
//tree require("./codebase/connector/tree_group_connector.php"); $tree = new TreeGroupConnector($res); $tree->render_table("products2", "id", "product_name", "", "category"); //treeGrid <code php> require_once('../../codebase/treegridgroup_connector.php'); $treegrid = new TreeGridGroupConnector($res,"MySQL"); $treegrid->render_table("products2","id","product_name,scales,colour","","category");
Back to top