I try to make a loop in that each iterate item will be added to children of previous one. and it will be element of next one
subnodes ={
id : "value1",
text:"value1",
children:[]
};
temp ={};
allnodes = ["value2","value3","value4",...]
$.each(allnodes,function(index, value){
newObject = {
id : value,
text:value,
children:[]
};
subnodes.children.push(newObject)
});
after loop result should be like this:
{
id:"value1",
text:"value1"
children:[
{
id:"value2",
text:"value2",
children:[
{
id:"value3",
text:"value3",
children[{
id:"value4",
text:"value4",
children[..]
}]
}
]
}
]
}