Hi,
I would like to get tree data which is dynamically created based on file paths list from function and load that tree data onto tree view. I am not able to see tree view with created data.
My code is as below:
<script type="text/javascript" charset="utf-8">
var treeData={};
var idDict={};
// TABLE INITIAL DATA
var tableData=[];
function addToDict(path){
l=path.split("/").slice(1,path.length);
// CHECK IF EMPTY DICTIONARY
if (Object.keys(treeData).length==0){
var prevDict1={};
for (var num=l.length; num>0; num--){
var id="1";
element=l[num-1];
var list1=[];
var dict1={};
for (var i=1; i < num; i++){
id=id+".1";
}
dict1["id"]=id;
dict1["value"]=element;
list1.push(prevDict1);
if (num!=l.length){
dict1["data"]=list1;
}
prevDict1=dict1;
if (num==1){
treeData=dict1;
}
}
}
else{
parseMainDict(l)
}
}
function parseMainDict(l){
//FUNCTIONALITY REMOVED DUE TO SPACE CONSTRAINT
}
function createDict(l, id){
//FUNCTIONALITY REMOVED DUE TO SPACE CONSTRAINT
}
function getTreeData(){
var list4=[];
var pathList=['/demo/container1/ABC_01/Inputs/test_enable',
'/demo/container1/ABC_02/Inputs/test_enable',
'/demo/container1/ABC/Inputs/test_enable',
'/demo/container1/ABC_16/Inputs/dsp_output',
'/demo/container1/ABC_16/Outputs/test_passed'];
for (path of pathList){
addToDict(path);
}
console.log(treeData);
return list4.push(treeData);
}
webix.ready(function(){
//loading from file
webix.ui({
type:"space",
margin:2,
padding:0,
autowidth:false,
container:"testA",
rows:[
{
view:"toolbar",
height: 50,
cols:[
{template:"<div class='header_comment'>Data Points Explorer</div>"},
{ view:"button", value:"Delete", width:100, click:function(){
$$("datatable1").remove($$("datatable1").getSelectedId());
}
}
]
},
{view:"resizer"},
{
cols:[
{
view:"tree",
width:400,
drag:"source",
select:true,
url:function(params){
return getTreeData();
},
}]
}]
});
});
</script>