I am trying to load the sections of a timeline view in tree mode from a database, but it doesn’t appear to be working. Here is a snippet:
$p_sql = "SELECT p.id as value, p.title as label, parent FROM product p";
$pi_sql = "SELECT pi.* FROM product_item pi ";
$calendar = new SchedulerConnector($res);
$list = new OptionsConnector($res);
$list->render_sql($p_sql,"product_id","id(value),title(label)","","parent");
$calendar->set_options("product", $list);
$calendar->render_sql($pi_sql,"id","start,end,title,product_id,monetization_level","product_id");
In testing, I have one “child” item in the product table with the “parent” field set correctly. But when I display the view, the child item shows up as its own top-level element, not under the parent.
Hi, I am also trying to load sections from a table, a users table to be precise. How would I be able to do this. I noticed someone mentioned client side ? Any details on how I would do this thanks!
Hello,
TreeTimeline can load sections as a tree structure, i.e 1)[
{key:1, label:"root", children:[
{key:2, label:"child"},
{key:3, label:"child 2"},
..
],
{key:4, label:"second node", ...}
]
When, you retreive data from the database, most probably you deal with plain structure like following: 2)[
{id:1, text:"root", parent_id:0},
{id:2, text:"child", parent_id:1},
{id:3, text:"child 2", parent_id:1},
So you need to iterate array of elements b[/b] and build a tree b[/b] that can be consumed by TreeTimeline. It can be done either on server or on client.
I don’t think that’s the cleanest and fastest way (I’d like to use the OptionsConnector and $conn->set_options of the connector), but it works. Any advice is welcome!
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan