Ticket Q300212
Visible to All Users

ASPxTreeList - How to iterate through selected nodes

created 14 years ago

Hi,
This is regarding the ASPXTrrList view. I would like to get the selected node value. But I need to fetch the ID instead of the Value.
Herewith I have attached a sample image for my TreeList. Whenever the user click on the node then we need to fetch the selected node value. (i.e same like drop down selection)
FYI…
Here is the FE code what we are using for our application.
Dim treeListAnalysis As ASPxTreeList = CType(cboTreeView.FindControl("tvUserTree"), ASPxTreeList)
                Dim rootNode As TreeListNode = Nothing
                Dim taskType As String = Nothing
                Dim rootValue As Integer = 0
                userList = TaskListManager.GetTreeListView()
                configXML = CType(Profile.DocTas.Web.Common.GetCache(), XmlDocument)
                nodeList = configXML.SelectNodes("XXX/YYYY/NODE")
                For loopCounter = 0 To nodeList.Count - 1
                    For innerLoopCounter = 0 To nodeList(loopCounter).ChildNodes.Count - 1
                        rootNode = treeListAnalysis.AppendNode(rootValue)
                        rootNode.SetValue("name", nodeList(loopCounter).ChildNodes(innerLoopCounter).ChildNodes(0).InnerXml)
                        rootValue = rootValue + 1
                        If nodeList(loopCounter).ChildNodes(innerLoopCounter).ChildNodes(0).InnerXml = "Other Departments Task" Then
                            taskType = "Department"
                            Dim userSelection = From value In userList Where taskType.Equals(value.UserType)
                            For Each result In userSelection
                                treeListAnalysis.AppendNode(rootValue, rootNode).SetValue("name", result.UserName)
                                rootValue = rootValue + 1
                            Next
                        End If
                        If nodeList(loopCounter).ChildNodes(innerLoopCounter).ChildNodes(0).InnerXml = "Other Teams Task" Then
                            taskType = "Team"
                            Dim userSelection = From value In userList Where taskType.Equals(value.UserType)
                            For Each result In userSelection
                                treeListAnalysis.AppendNode(rootValue, rootNode).SetValue("name", result.UserName)
                                rootValue = rootValue + 1
                            Next
                        End If
                    Next
                Next
I am awaiting for your reply.
Thanks,
Vinoth Kumar R

Answers approved by DevExpress Support

created 14 years ago (modified 11 years ago)

Hello Vinoth,
Thank you for sending the code block to me. I have examined it and suggest that you modify your scenario a little. Since it is necessary to iterate through the ASPxTreeList's ASPxTreeList.Nodes collection, it is recommended to use the TreeListNodeIterator.
Please use the approach, illustrated in the OBSOLETE: How to change the style of a parent node's selection checkbox if some of its child nodes are selected Code Central example, as a starting point to accomplish this task (the ASPxTreeList1_SelectionChanged event handler).
Thanks,
Mike

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.