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

NodeClick clears out the content of Node Templates

1 Answer 59 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 20 Nov 2008, 09:34 AM

Hi

I’ve got a problem with the server-side Event „.NodeClick“. Every time the Ajax postback is complete all nodes from the selected nodes up to the root nodes and all its child nodes in the tree view got cleared out. They only show their + or – images and the Line Images.  I use a default node template with a label in it. Without templates it only resets properties like „ForeColor” to black, but the text stays visible.  I also use Client-Side Load On Demand with „ServerSideCallback“. The NodeClick event changes some text in a label on the webform.  Booth, the tree view and the label are located in separated updatepannels. I’ve created a sample project to eliminate side effects generated by my other code but the problem is still present.  Can someone tell me what I’m doing wrong?


There is also another problem with the loading image I use in the LoadingStatusTemplate. If I use Node Templates, the image never shows up on the right side of the node but on its bottom side. Without Node Templates it shows up at the right side like expected. Is there a way to get the image on the right end of the node when I’m using Node Templates?

Thanks a lot for your help!


This is the code of my sample project:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="frmTest2.aspx.vb" Inherits="frmTest2" %> 
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head id="Head1" runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <div> 
        <asp:UpdatePanel ID="UpdatePanel1" runat="server"
            <ContentTemplate> 
                <asp:Button ID="Button1" runat="server" Text="poppulate!" /> 
                <asp:Label ID="lbltest" runat="server" Text="Label"></asp:Label> 
            </ContentTemplate> 
        </asp:UpdatePanel> 
        <asp:UpdatePanel ID="UpdatePanel2" runat="server"
            <ContentTemplate> 
                <telerik:RadTreeView ID="rtvAtcTree" runat="server" LoadingStatusPosition="AfterNodeText" 
                    EnableDragAndDrop="True" EnableDragAndDropBetweenNodes="True" TabIndex="1" EnableEmbeddedSkins="True"
                    <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation> 
                    <ExpandAnimation Duration="100"></ExpandAnimation> 
                    <NodeTemplate> 
                        <asp:Label ID="lblNodeText" runat="server" Text=""></asp:Label> 
                    </NodeTemplate> 
                    <LoadingStatusTemplate> 
                        <img src="Images/loading.gif" alt="" /> 
                    </LoadingStatusTemplate> 
                </telerik:RadTreeView> 
            </ContentTemplate> 
        </asp:UpdatePanel> 
    </div> 
    </form> 
</body> 
</html> 

Imports System 
Imports System.Data 
Imports System.Collections.Generic 
Imports Telerik.Web.UI 
 
 
Partial Class frmTest2 
    Inherits System.Web.UI.Page 
 
 
    Protected Sub rtvAtcTree_NodeClick(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles rtvAtcTree.NodeClick 
        lbltest.Text = Now 
    End Sub 
 
 
    Protected Sub rtvAtcTree_NodeExpand(ByVal sender As ObjectByVal e As RadTreeNodeEventArgs) Handles rtvAtcTree.NodeExpand 
        Me.RenderSubNodes(e.Node) 
        e.Node.Expanded = True 
    End Sub 
 
 
    Private Sub RenderSubNodes(ByVal ParentNode As RadTreeNode) 
 
        For i As Integer = 0 To 3 
 
            Dim n As New RadTreeNode 
            n.ExpandMode = TreeNodeExpandMode.ServerSideCallBack 
            If ParentNode Is Nothing Then 
                rtvAtcTree.Nodes.Add(n) 
            Else 
                ParentNode.Nodes.Add(n) 
            End If 
            ApplyNodeText(n, "Text"
 
        Next 
 
    End Sub 
 
 
    Private Sub ApplyNodeText(ByVal node As RadTreeNode, ByVal txt As String
        Dim lblNodeText As Label 
        lblNodeText = node.FindControl("lblNodeText"
        lblNodeText.Text = txt 
    End Sub 
 
 
    Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click 
        Me.RenderSubNodes(Nothing
    End Sub 
 
End Class 

1 Answer, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 21 Nov 2008, 03:27 PM

I solved the problem by changing the ExpandMode from “ServerSideCallBack” to “ServerSide”. But I’m still confused about why this happens. Also this solution reduces the performance in a significant way on already loaded nodes…


Tags
TreeView
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Share this question
or