Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
190
Server side Node Expanded Event needs 3 clicks to fire
posted

I have a web application project with Infragistics 2014.2 and .net Framework 4. In my web page I put a WebDataTree that is loaded only the first level of nodes. I need to get server side events every time a node is clicked or the node's expand button is clicked in order to decide programmatically if the child nodes need to be loaded.

This scenario works fine but the user needs to click three times the expand button to fire the server side event. This happened only when the node has no children loaded. If a node has children loaded the expand events working fine.

I created a small example showing this issue.

Default.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebDataTreeTest._Default" %>
<%@ Register Assembly="Infragistics4.Web.v14.2, Version=14.2.20142.2480, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.NavigationControls" TagPrefix="ig" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <ig:WebDataTree ID="WebDataTree1" runat="server" Height="600" Width="400px"
            CheckBoxMode="BiState" NodeIndent="18" EnableAjaxViewState="true"
            OnNodeClick="WebDataTree1_NodeClick" OnNodeExpanded="WebDataTree1_NodeExpanded">
            <AutoPostBackFlags NodeClick="On" NodeExpanded="On" />
        </ig:WebDataTree>
    </div>
    </form>
</body>
</html>

Default.aspx.vb

Public Class _Default
    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
            For i As Integer = 1 To 5
                Dim tn As New Infragistics.Web.UI.NavigationControls.DataTreeNode()
                tn.Key = "1"
                tn.Value = "N|" & i.ToString()
                tn.Text = "Node" & i.ToString()
                tn.ToolTip = tn.Text
                tn.IsEmptyParent = True
                tn.Expanded = False
                WebDataTree1.Nodes.Add(tn)
            Next
        End If
    End Sub

    Protected Sub WebDataTree1_NodeClick(sender As Object, e As Infragistics.Web.UI.NavigationControls.DataTreeNodeClickEventArgs)
        If e.Node.HasChildren Then
            e.Node.Expanded = Not e.Node.Expanded
            Exit Sub
        End If
        AddNodes(e.Node)
        e.Node.Expanded = True
    End Sub

    Protected Sub WebDataTree1_NodeExpanded(sender As Object, e As Infragistics.Web.UI.NavigationControls.DataTreeNodeEventArgs)
        If e.Node.HasChildren Then
            Exit Sub
        End If
        AddNodes(e.Node)
        e.Node.Expanded = True
    End Sub

    Private Sub AddNodes(parentNode As Infragistics.Web.UI.NavigationControls.DataTreeNode)
        For i As Integer = 1 To 5
            Dim tn As New Infragistics.Web.UI.NavigationControls.DataTreeNode()
            tn.Key = CStr(Integer.Parse(parentNode.Key) + 1)
            tn.Value = "N|" & parentNode.Value.Split("|")(1) & i.ToString()
            tn.Text = "Node" & parentNode.Value.Split("|")(1) & i.ToString()
            tn.ToolTip = tn.Text
            tn.IsEmptyParent = True
            tn.Expanded = False
            parentNode.Nodes.Add(tn)
        Next
    End Sub

End Class

Parents Reply
  • 2671
    Offline posted in reply to Leo

    Hello Leo,

    I believe I get your second case – you want to confirm the node expand action in a sense, right? Like a conditional manual load on demand. The population of node data is, however, strictly asynchronous. You could attempt to skip populating the node and force a postback after the population is "complete", but that would kind of go against the load on demand feature entirely.

    The most straightforward solution I can think of is to cancel the client side NodePopulating event and save the node reference for later. Then go thought the user confirmation (show a dialog for example) and only after the user accepts, expand the node, which will go through the normal populating process as usual. This seems to make the most sense, so let me know if this is suitable for your case and I will try to provide more guidance on how to achieve that.

    Regards,

    Damyan Petev

    Associate Software Developer

    Infragistics, Inc.

Children