var getTree=function(treeData,parentId){
var treeArr=[];
for(var i=0; i< treeData.length; i++){
var node=treeData[i];
if(node.sjchannelcode==parentId ){
var newNode={order:node.order,code:node.channelcode,url:node.url,name:node.name,sjchannelcode:node.sjchannelcode,channelcode:getTree(treeData,node.channelcode)};
treeArr.push(newNode);
}
}
return treeArr;
}
// call tree method
var treeArr=getTree(data,sj);
data is the data returned from the background, sj root directory returned by the node parent id
Read More:
- Use XMLHttpRequest of JavaScript to send data to the background
- Datagrip import & export table structure and data
- [Solved] Es delete all the data in the index without deleting the index structure, including curl deletion
- C # generate data in DataGridView into XML file
- Vue—— Error: Redirected when going from “/“ to “/directory/tree“ via a navigation guard
- Unable to resolve dependency tree
- check a tree is balanced or not
- Binary tree traversal (preorder, middle order, postorder, hierarchy traversal, depth first, breadth first)
- How to receive localdatetime type in background
- Inconsistency between adapter data and UI data after dragging recyclerview (data disorder)
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)
- InnoDB, tokudb, MyISAM directory structure
- PHP uses timthumb to generate thumbnails
- Resolve Tree Conflict SVN
- Cocos creator 2.4.5 2D RPG (Infinite scrolling background implementation)
- Failed to load viewstate.The control tree into which viewstate is being loaded must match the contro…
- Wechat applet background image error
- Failed to load response data:No data found for resource with given identifie
- How to generate PDF by C #
- Viewing Android dependency tree using gradle