Ext.Net如何获取所有TreeNode IN TreePanel AS List <node>

时间:2018-03-31 12:43:26

标签: extjs ext.net

Ext.Net如何获取TreePanel AS列表中的所有TreeNode

foreach(Node treenode in treepanel.Nodes) {
   string nodeID = treenode.NodeID;
}

1 个答案:

答案 0 :(得分:0)

你可以递归地做到:

    //Create a list 
    List<Node> list = new List<Node>();

    //pass you tree root as a parameter
    GetAllNodes(YourTreePanel.root);


    protected void GetAllNodes(NodeCollection nodes) {

        foreach (Node item in nodes)
        {  
            //if your node has children call the function again                
            if (item.Children.Count > 0) GetAllNodes(item.Children);

            //finally add the node to the list 
            list.Add(item);
        }
    }
相关问题