Posted: 4 Oct 2016 18:42 EDT Last activity: 26 Aug 2020 8:17 EDT
Creating an Expandable List
Is there a built-in component within OpenSpan that allows for displaying a list with hierarchical elements? I'm trying to create a list with certain items having an expandable view due to sub-items, but I'm not sure which component I should be using. The TreeView component sounds like what I'm looking for but I'm not sure how to add parent items vs sub items into it. Any help or creative solutions would be appreciated!
The treeview definitely sounds like the component that you should try using. The treeview component is a .NET component that can be added to the Windows Form using the toolbox.
The component has properties that allow you to configure the treeview's appearance and behavior. Along with the designer configurations there is also a property called "Nodes" which allows you to add a collection of nodes to the treeview.
When clicking the collections elipse of the nodes property you are provide a new window that allows you to add root and child nodes perspectively to what is selected in the left panel node list. The right panel provides additional configuration settings for how the nodes are displayed. Please have a look at the attached screenshot for futher illustration.
The node list definitely looks like what I'm looking to achieve; however, could you point me to the correct methods to use to dynamically add the nodes and child nodes? Right now I'm running a few loops that basically checks for any sub fields associated with a parent field. There will be several parent fields so ideally the loop could add the sub field items as child while the parent field could be added from the loop as root nodes.
Here is how you would do it. This example assigns the key and the text to each TreeNode as the same value and expects that each is unique. You may add root nodes directly, but before adding child nodes you must select the parent node for the child.
Here is the AddSubNode automation:
To create these automations you will need to go to the Explore Component Properties section for the TreeView:
Select Nodes and you will find the methods as seen below: