NodeExpand event fires twice

6 posts, 0 answers
  1. niv kfir
    niv kfir avatar
    21 posts
    Member since:
    Apr 2010

    Posted 12 Aug 2010 Link to this post

    Hi,
    I'm populating a treeView with: 
     TreeNodeExpandMode.ServerSideCallBack

    and:
     <telerik:RadTreeView ID="tvScannedURLs" runat="server" 
                OnNodeExpand="tvScannedURLs_NodeExpand">
    </telerik:RadTreeView>

    My problem is that the tvScannedURLs.NodeExpand event is fires twice for every expand of a node on the tree.
    It has no connection to the PostBack property of the page.

    Any idea why?
    Thanks,
    Niv.

  2. niv kfir
    niv kfir avatar
    21 posts
    Member since:
    Apr 2010

    Posted 13 Aug 2010 Link to this post

    I solved this by adding a flag - Set on the first time the event fires,
    and reset on page PostBack.

    Not very elegant, but works.
    Thanks,
    Niv.

  3. Ryan Ewing
    Ryan Ewing avatar
    3 posts
    Member since:
    Mar 2010

    Posted 26 Aug 2010 Link to this post

    I have this same problem, I don't really understand what you did, but wrapped the entire function with an "If not e.node.hasControls then", If the node calling this has controls, I know the event has already been fired once.

    Is there any progress on why this is happening?
  4. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 27 Aug 2010 Link to this post

    Hello,

    Could you please paste some sample code which will help us reproduce the issue?

    Greetings,
    Yana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Ryan Ewing
    Ryan Ewing avatar
    3 posts
    Member since:
    Mar 2010

    Posted 27 Aug 2010 Link to this post

    He is a simple example where this happens:

    aspx

     

     

    <%@ Page Title="" Language="VB" MasterPageFile="~/Research.master" AutoEventWireup="false" CodeFile="treetest.aspx.vb" Inherits="treetest" %>
      
    <asp:Content ID="Content1" ContentPlaceHolderID="cHead" Runat="Server">
      
    </asp:Content>
      
    <asp:Content ID="Content2" ContentPlaceHolderID="cc" Runat="Server">
      
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
      
    </telerik:RadScriptManager>
      
    <telerik:RadTreeView ID="RadTreeView1" runat="server" Height="300px" Width="400px" OnNodeExpand="RadTreeView1_NodeExpand">
      
    </telerik:RadTreeView>
      
    </asp:Content>

     




    aspx.vb

    Partial Class treetest
      
    Inherits System.Web.UI.Page
      
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
    If Not IsPostBack Then
      
    For i As Integer = 0 To 10
      
    Dim sectionNode As Telerik.Web.UI.RadTreeNode = New Telerik.Web.UI.RadTreeNode
      
    sectionNode.Text = i.ToString
      
    sectionNode.Value = i.ToString
      
    sectionNode.ExpandMode = Telerik.Web.UI.TreeNodeExpandMode.ServerSideCallBack
      
    sectionNode.PostBack = False
      
    RadTreeView1.Nodes.Add(sectionNode)
      
    Next
      
    End If
      
    End Sub
      
    Protected Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeExpand
      
    Dim sectionNode As Telerik.Web.UI.RadTreeNode = e.Node
      
    For i As Integer = 0 To 10
      
    Dim pageNode As Telerik.Web.UI.RadTreeNode = New Telerik.Web.UI.RadTreeNode
      
    pageNode.Text = sectionNode.Value & i.ToString
      
    pageNode.Value = sectionNode.Value & i.ToString
      
    sectionNode.Nodes.Add(pageNode)
      
    Next
      
    'sectionNode.Expanded = True
      
    End Sub
      
    End Class

    if you put a breakpoint on radtreeview1_nodeExpand you will see that is fires twice for each click, also it put the subnodes in twice.

     

     

  6. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 30 Aug 2010 Link to this post

    Hello Ryan,

    You should subscribe to the event either in the markup or in the code-behind with  "Handles", so please remove one of the these and the event will be fired only once as expected.

    Kind regards,
    Yana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top