Mar 14, 2014, 4:56 PM
[CLOSED] Reloading TreePanel Nodes dynamically in a Direct Event
I have a TreePanel with a Node and I need to load the tree based on user input from a combo box. The items/text etc. in the nodes are derived from a database query (linq objects). There are also things that are removed based on who is logged in etc. so my load/reload needs to be in code behind direct event in order to access the data model. When the form loads, the tree/nodes are loaded and looks great. When my direct even is called, the nodes in the form are not refreshed. My searches for this in this forum returns all 1.x related problems.
Thanks in advance,
Robb
Thanks in advance,
Robb
<ext2:TreePanel ID="menuActions" runat="server" RootVisible="false" Border="false">
<Root>
<ext2:Node NodeID="root" Text="Actions" Expanded="true" />
</Root>
</ext2:TreePanel>
<DirectMethod()>
Public Sub ContextSelect(sender As Object, e As DirectEventArgs)
Dim root As Ext.Net.Node = menuActions.Root.Primary
Dim groups As New SortedDictionary(Of String, Ext.Net.Node)
Dim groupleaves As New SortedDictionary(Of String, SortedDictionary(Of String, Ext.Net.Node))
Dim leaves As New SortedDictionary(Of String, Ext.Net.Node)
' actions is an ienumerable with data rows specific to user input
For Each a In actions.OrderBy(Function(o) o.Group_vc).ThenBy(Function(o) o.Name_vc)
If Not groups.ContainsKey(a.Group_vc) Then
Dim treeNode As New Node
With treeNode
.Text = a.Group_vc
.Icon = Icon.Folder
.Expanded = True
End With
groups.Add(a.Group_vc, treeNode)
leaves = New SortedDictionary(Of String, Ext.Net.Node)
End If
If Not groupleaves.ContainsKey(a.Group_vc) Then
leaves.Add(a.Key_vc, New Ext.Net.Node With {
.NodeID = a.Key_vc,
.IconFile = ActionNewBasePage.GetImage(a),
.Leaf = True,
.Text = a.Name_vc
})
groupleaves.Add(a.Group_vc, leaves)
Else
groupleaves(a.Group_vc).Add(a.Key_vc, New Ext.Net.Node With {
.NodeID = a.Key_vc,
.IconFile = ActionNewBasePage.GetImage(a),
.Leaf = True,
.Text = a.Name_vc
})
End If
'then add the node to the group
Next
''add the group nodes to the root
For Each kvp In groups
For Each nkvp In groupleaves(kvp.Key)
kvp.Value.Children.Add(nkvp.Value)
Next
root.Children.Add(kvp.Value)
Next
End Sub
Last edited by Daniil; Mar 17, 2014 at 11:54 AM.
Reason: [CLOSED]