chniter / bstreeview

Bootstrap Treeview, A very simple plugin to build a basic and elegant Treeview with bootstrap 4. See the demo:
https://chniter.github.io/bstreeview/
Apache License 2.0
367 stars 53 forks source link

Refreshing or reloading updated tree ? #30

Open Mjalid opened 2 years ago

Mjalid commented 2 years ago

I reset the tree and reload a new updated tree but no success : $('#tree').html(''); // $('#tree').bstreeview({ data: json, // a New json expandIcon: 'fa fa-angle-down fa-fw', collapseIcon: 'fa fa-angle-right fa-fw', indent: 1.25, parentsMarginLeft: '1.25rem', openNodeLinkOnNewTab: false }); Does anyone have a solution for this please ? Many thanks

salihahmp commented 2 years ago

@Mjalid Are u able to find the solution?

I try this code ;

$('#tree').empty(); //to empty the div $('#tree').removeData(); // to recall the js function (need to put or else it will not show any treeview)

You can try replace above code with $('#tree').html(''); //, see if it works, because it works on my side.

bala-sakthis commented 1 year ago

Note: This works in v1.0.0.

Based on the solution provided by @chniter in Issue #24, do the below:

  1. Remove the TreeView element. $('#TreeViewDiv').remove();

  2. Append the TreeView element. $('#ParentDiv').append('<div id="TreeViewDiv"></div>');

  3. Build the TreeView again.

    $('#TreeViewDiv').bstreeview({
    data: JSON.stringify(treeViewData),
    expandIcon: 'fa fa-angle-down fa-fw',
    collapseIcon: 'fa fa-angle-right fa-fw',
    indent: 1.25,
    parentsMarginLeft: '1.25rem',
    openNodeLinkOnNewTab: true
    });