This is a migrated thread and some comments may be shown as answers.

NodeExpand event firing twice

5 Answers 110 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
jorge
Top achievements
Rank 1
jorge asked on 10 Apr 2008, 01:41 PM

I am trying to implement load on demand on a tree.  For some reason the NodeExpand event is firing twice duplicating the nodes. 

Here is the ASPX code:

<%@ Page Language="VB" ValidateRequest="False" AutoEventWireup="true" CodeFile="layerProfiles.aspx.vb" Inherits="layerProfiles" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Layer Profiles</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <div style="width: 250px; float:left">  
        <telerik:RadTreeView ID="availableLayersTree" runat="server" OnNodeExpand="availableLayersTree_NodeExpand">  
        </telerik:RadTreeView> 
    </div> 
    <div style="width: 250px; float:left">  
        <telerik:RadTreeView ID="userTree" runat="server">  
            <CollapseAnimation Type="OutQuint" Duration="100" /> 
            <ExpandAnimation Duration="100" /> 
        </telerik:RadTreeView> 
    </div> 
    </form> 
</body> 
</html> 
 

and the VB code, modified just to test adding a single node:
Imports Telerik.Web.UI  
 
Partial Class layerProfiles  
    Inherits System.Web.UI.Page  
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
        If Not Page.IsPostBack Then  
            'generateTree()  
            loadRootNodes()  
        End If  
    End Sub  
 
    Private Sub loadRootNodes()  
        Dim oRootGroups As New GeoNet.LayerGroupsCollection  
        oRootGroups.LoadGroups(False)  
 
        Dim oGroup As GeoNet.LayerGroup  
        Dim oParentNode As RadTreeNode  
        For Each oGroup In oRootGroups  
            If oGroup.ShowInLegend = "true" Then  
                oParentNode = New RadTreeNode(oGroup.LegendLabel, oGroup.ID)  
                oParentNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack  
                availableLayersTree.Nodes.Add(oParentNode)  
            End If  
        Next  
        oParentNode = New RadTreeNode("New Layer Profile")  
        userTree.Nodes.Add(oParentNode)  
    End Sub  
 
    Protected Sub availableLayersTree_NodeExpand(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles availableLayersTree.NodeExpand  
        'Dim oAuxGroupsCollection As New GeoNet.LayerGroupsCollection  
        'Dim oOriginatingGroup As New GeoNet.LayerGroup(e.Node.Value)  
        'oOriginatingGroup.Children = oAuxGroupsCollection.BuildGroupTree(oOriginatingGroup)  
 
        'If Not oOriginatingGroup.Children Is Nothing Then  
        '    Dim oChildGroup As GeoNet.LayerGroup  
        '    For Each oChildGroup In oOriginatingGroup.Children  
        '        If oChildGroup.ShowInLegend = "true" Then  
        e.Node.Nodes.Add(New RadTreeNode("test", "100"))  
        '        End If  
        '    Next  
        e.Node.Expanded = True 
        e.Node.ExpandMode = TreeNodeExpandMode.ClientSide  
        'End If  
    End Sub  
End Class  
 

What setting am I missing?

5 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 10 Apr 2008, 02:10 PM
Hello jorge,

I suggest that you remove OnNodeExpand="availableLayersTree_NodeExpand"
from the treeview declaration (since in the .vb file you already have Handles availableLayersTree.NodeExpand)

I hope this helps.

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
jorge
Top achievements
Rank 1
answered on 10 Apr 2008, 02:16 PM
Veskoni,

Thank you for the prompt response.  Yeah, that did it.  I suggest you check the code on your online example since it also has OnNodeExpand="RadTreeView1_NodeExpand".

Jorge
0
Veselin Vasilev
Telerik team
answered on 10 Apr 2008, 02:26 PM
Hi jorge,

We already fixed that. It will be available on the site next week when we are releasing the official Q1 version of the Prometheus controls.

Sincerely yours,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
jorge
Top achievements
Rank 1
answered on 10 Apr 2008, 02:41 PM
Excellent, thanks again for the outstanding support.

Jorge
0
Gordon Buxton
Top achievements
Rank 1
answered on 06 Jun 2008, 11:59 AM
I had exactly the same issue, caused by copying and pasting the sample code, which does not seem to have been updated yet!

At least I learned something.
Tags
TreeView
Asked by
jorge
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
jorge
Top achievements
Rank 1
Gordon Buxton
Top achievements
Rank 1
Share this question
or