Dhtmlx treeview clear contents before reloading

Hi,

I am facing 2 problems in Tree view.

  1. How to clear the contents of tree view before binding ? Currently the data is getting appended with the previous content.
  2. The parent folder is not showing up in the tree view.

The data which I’m trying to bind is given below:

{id = 0, text = "012017", item = { id = "newfile", text = "newfile.txt" } , {id = "testdata", text = "testdata.txt"} };

and I could see only p.txt and q.txt not the folder name 012017… what would be the reason?

Thanks,
Durga V.

  1. Please, try to use the clearAll() method:
    docs.dhtmlx.com/api__dhtmlxtree … arall.html
  2. Unfortunately the problem cannot be reconstructed locally. Please, provide with a complete demo, or share with demo link, where the problem could a be reconstructed locally.
    Here you can find a tutorial about creating a complete demo:
    docs.dhtmlx.com/tutorials__auxi … pport.html

Thank you Sematik.

For the first issue, How to clear the contents of tree view before binding ? I used

and it worked for me.
The data to bind is from Ajax call in json format. So, I will share the data(please find the screenshot) and javascript code.
The fnInitTree function is called on load.

function fnInitTree() { $("#treeFilterContainer").html(""); userTree = new dhtmlXTreeObject("treeFilterContainer", "100%", "100%", 0); userTree.setSkin('dhx_skyblue'); userTree.setImagePath("../Scripts/tree/imgs/csh_bluebooks/"); userTree.attachEvent("onclick", function (id, text) { PreviewLogFile(id); }); }

and this is the callback function from Ajax POST.

var callBack = function fnSaveSuccess(msg) { if (msg.success == true) { $("#treeFilterContainer").css('display', 'block'); var result = msg.TreeData; userTree.deleteChildItems(0); userTree.loadJSONObject(result); } }

Would this details help me?

Thank you
Durga V.

In case of using the dhtmlxTree (not dhtmlxTreeView) please, try to use the deleteChildItems() method to clear the tree content.