Closed asadghazanfary closed 8 years ago
Hi, For the moment we can't add or refresh items, a workaround could be building the timeline only once json records are retrieved, but I think you won't be able to update it later... (could it work for you?)
It's a very important point so I'll work on that after horizontal mode. Thx!
Hi, any feedback on this?
Hi @jcr4e, thanks for the follow up, I've been quite absent last weeks... Just added this on the TODO list, will try to work on it this WE!
@jcr4e @asadghazanfary just added a first try of dynamic load, if you have some time to check it and give me some feedback (some limitations you faced, issue, ...) don't hesitate. Cheers!
This is how I do it:
public function displayTree() { ... your SQL query here.. table must have id and parent_id fields $this->makeTree($nodes, 0, $tree); echo json_encode($tree); } private function makeTree( $rst, $level, &$tree ) { for ( $i=0, $n=count($rst); $i < $n; $i++ ) { if ( $rst[$i]['parent_id'] == $level ) { $branch = array( 'name' => $rst[$i]['step'], 'id' => $rst[$i]['id'], 'step_id' => $rst[$i]['step_id'], 'parent_id' => $rst[$i]['parent_id'], 'children' => array() ); $this->makeTree( $rst, $rst[$i]['id'], $branch['children'] ); $tree[] = $branch; } } }
you can then run displayTree using AJAX and load the result on the tree. check sample code below:
$('#treeview').tree({
data: result,
autoOpen: true,
dragAndDrop: true,
closedIcon: '+',
openedIcon: '–'
});
hope this helps.
Ok so normally you should be able to use it that way. Tell me if I missed something ;)
how can add dynamically items with json records retrive from database?