View Full Version : [CLOSED] Reloading TreePanel Nodes dynamically in a Direct Event

Mar 14, 2014, 4:56 PM
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,

<ext2:TreePanel ID="menuActions" runat="server" RootVisible="false" Border="false">
<ext2:Node NodeID="root" Text="Actions" Expanded="true" />

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)
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

''add the group nodes to the root
For Each kvp In groups
For Each nkvp In groupleaves(kvp.Key)
End Sub

Mar 17, 2014, 5:02 AM
Hi @Robb,

If you change a TreePanel's Root during a DirectEvetn, it won't affect to client automatically. You can call a TreePanel's Render method


Then an entire TreePanel will be re-rendered with new nodes.

Another possible approach is:

Mar 17, 2014, 11:31 AM
Thanks, I was trying DoLayout but Render is what I was missing.