Refresh Bootstrap Treeview programmatically
13,108
Solution 1
Just call:
$('#tree').treeview({data: data,
onNodeSelected: function(event, data) {
$m.nodeSelected(event,data);
}
});
again when you have changed the data
variable:
example: https://jsfiddle.net/k8m911u9/1/
Solution 2
Thi is possible in development version: https://github.com/jonmiles/bootstrap-treeview/tree/develop there is added metods for add, delete, update node
Author by
tarzanbappa
I am a Programmer who is willing to learn and help each other.
Updated on June 04, 2022Comments
-
tarzanbappa almost 2 years
I have a Bootstrap tree view which binds to a json array..
$('#tree').treeview({data: data, onNodeSelected: function(event, data) { $m.nodeSelected(event,data); }});
And the array that binded to the treeview is..
var data = [ { "text": "Parent1", "selectable": "false", "nodeType": "main", "nodes": [ { "text": "Child1", "typeId": "aa2d4ea9-bfad-4a5b-8794-994e7e482808", "nodeType": "sub" }, { "text": "Child2", "typeId": "e01bd0cb-c93b-40f9-be44-be67f20668aa", "nodeType": "sub" } ] }, { "text": "Parent2", "selectable": "false", "nodeType": "main", "nodes": [ { "text": "Child1", "typeId": "a0256aa3-b2ef-53d7-1270-a5029e7138ce", "nodeType": "sub" } ] } ]
Here is what I need..
I need to add a new child node / remove a existing child node from the treeview datasource and refresh it.
I've tried but unable to find a solution.
-
Ray Hulha over 5 years$('#tree').treeview(true).removeNode([]); // refresh hack