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

RadTreeView not showing ability to expand structure

1 Answer 117 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Scott MacDonald
Top achievements
Rank 1
Scott MacDonald asked on 06 Mar 2009, 04:23 PM
I am working with a load on demand version within a tabbed view and within a splitter. I create my first node with the idea that when you click on the plus sign you can expand to the next node, but my plus signs do not show up in this example. It seems that the ExpandMode="ServerSideCallBack" is not working at all. I am finding simple formats are working but even the imageurl I have passed is not showing either. Thoughts on what I might be doing wrong or am missing?

See code here:

 

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="TabTwoVB.ascx.vb" Inherits="Admin_TabTwoVB" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<link href="../smart.css" rel="stylesheet" type="text/css" />
<table cellspacing="0" cellpadding="15" width="100%" border="1">
    </tr>
    <tr>
        <td  style="background-color: #f3f3f3">
            <telerik:RadSplitter ID="RadSplitter1" runat="server" Height="700" Width="820">
                <telerik:RadPane ID="LibraryPane" BackColor="#f3f3f3" BorderColor="#f3f3f3" runat="server" Width="60%"><br /><br />
                    <telerik:RadTreeView ID="RadTreeViewEP" runat="server" Skin="Outlook" AllowNodeEditing="True"
                        OnContextMenuItemClick="RadTreeViewEP_ContextMenuItemClick" OnClientContextMenuItemClicked="onClientContextMenuItemClicked"
                        OnClientContextMenuShowing="onClientContextMenuShowing"
                        OnNodeEdit="RadTreeViewEP_NodeEdit"
                        Font-Bold="True" Font-Names="Arial" Font-Size="10pt" ForeColor="#732928"
                        DataSourceID="SqlDataSource1" DataTextField="blkbkName"
                        DataValueField="blkbkID">
                        <Nodes>
                            <telerik:RadTreeNode runat="server" Expanded="False"
                                ExpandMode="ServerSideCallBack"
                                Font-Bold="True" Font-Names="Arial" Font-Size="10pt" ForeColor="#732928"
                                Height="22px">
                                <Nodes>
                                    <telerik:RadTreeNode runat="server" Font-Names="Arial" Font-Size="10pt"
                                        ForeColor="#732928" Height="22px" ImageUrl="~/Images/booksx.gif" ExpandMode="ServerSideCallBack">
                                        <Nodes>
                                            <telerik:RadTreeNode runat="server" Font-Names="Arial" Font-Size="9pt"
                                                ForeColor="#732928" Height="22px" ImageUrl="~/Images/books2x.gif">
                                            </telerik:RadTreeNode>
                                        </Nodes>
                                    </telerik:RadTreeNode>
                                </Nodes>
                            </telerik:RadTreeNode>
                        </Nodes>
                    </telerik:RadTreeView>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:SMARTConnectionString %>"
                        SelectCommand="INDSearchV5" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:SessionParameter DefaultValue="1" Name="SID" SessionField="CTECAdmin"
                                Type="String" />
                            <asp:SessionParameter DefaultValue="1" Name="NH" SessionField="NewHorizons"
                                Type="String" />
                            <asp:ControlParameter ControlID="ViewBy" DefaultValue="0" Name="TY"
                                PropertyName="SelectedValue" Type="Byte" />
                            <asp:ControlParameter ControlID="ViewBy" DefaultValue="0" Name="BR"
                                PropertyName="SelectedValue" Type="Byte" />
                            <asp:ControlParameter ControlID="txtContent" DefaultValue="0" Name="SrchX"
                                PropertyName="Text" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </telerik:RadPane>
                <telerik:RadSplitBar ID="RadSplitbar1" runat="server" CollapseMode="Forward"></telerik:RadSplitBar>
                <telerik:RadPane ID="DetailPane" runat="server" Scrolling="y" Height="30%">
                    <telerik:RadSplitter ID="RadSplitter2" runat="server" Orientation="Horizontal">
                        <telerik:RadPane ID="FilterPane" BackColor="#f3f3f3" runat="server">
                            <br />
                            <table>
                                <tr>
                                    <td align="left" colspan="2"><br /><br />
                                        &nbsp;<font face="Arial, Helvetica, sans-serif" color="#732928" size="2">View By:</font></td>
                                </tr>
                                <tr>
                                    <td align="left" colspan="2">
                                        <asp:RadioButtonList AutoPostBack="True" runat="server" ID="ViewBy"
                                            Font-Size="10pt" Font-Names="Arial" ForeColor="#732928"
                                            DataSourceID="SqlDataSource2" DataTextField="blkbkName"
                                            DataValueField="blkbkView">
                                            <asp:ListItem Selected="True" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                                            ConnectionString="<%$ ConnectionStrings:SMARTConnectionString %>"
                                            SelectCommand="INDRoles" SelectCommandType="StoredProcedure">
                                            <SelectParameters>
                                                <asp:SessionParameter DefaultValue="1" Name="SID" SessionField="ctecadmin"
                                                    Type="String" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </td>
                                </tr>
                           </table>
                       </telerik:RadPane>
                        <telerik:RadSplitBar ID="RadSplitbar2" runat="server" CollapseMode="Forward"></telerik:RadSplitBar>
                        <telerik:RadPane ID="ContentPane" BackColor="#f3f3f3" runat="server" Scrolling="Both" Height="70%">
                            <br />&nbsp;&nbsp;<font face="Arial, Helvetica, sans-serif" color="#732928" size="2">Hover Over Content</font>
                            &nbsp;&nbsp;&nbsp;<asp:textbox ID="txtContent2" runat="server" BorderColor="AliceBlue" Height="90%" Width="90%" Text="n.a." ></asp:textbox>
                        </telerik:RadPane>
                    </telerik:RadSplitter>
                </telerik:RadPane>
            </telerik:RadSplitter>
        </td>
    </tr>
</table>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="ViewBy">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadTreeViewEP" />
                <telerik:AjaxUpdatedControl ControlID="ViewBy" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
    height="75px" width="75px" HorizontalAlign="Center">
    <img alt="Loading..."
        src='../images/loading.gif'
        style="border:0px;" />
</telerik:RadAjaxLoadingPanel>

 

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Imports Microsoft.VisualBasic

Partial Class Admin_TabTwoVB
  Inherits System.Web.UI.UserControl

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
    'Put user code to initialize the page here

    If Not Page.IsPostBack Then
      Session("CtecAdmin") = 1
      Session("NewHorizons") = 1
    End If
  End Sub

  Protected Sub RadTreeViewEP_ContextMenuItemClick(ByVal sender As Object, ByVal e As RadTreeViewContextMenuEventArgs)
    Select Case e.MenuItem.Value
      Case "Copy"
        e.Node.InsertAfter(CloneNode(e.Node, String.Format("Copy of {0}", e.Node.Text)))
      Case "NewFolder"
        Dim newNodeTitle As String = String.Format("New Folder", e.Node.ParentNode.Nodes.Count + 1)
        e.Node.Nodes.Add(New RadTreeNode(newNodeTitle))
        e.Node.Expanded = True
    End Select
  End Sub

  Private Function CloneNode(ByVal original As RadTreeNode, ByVal text As String) As RadTreeNode
    Dim cloned As RadTreeNode = New RadTreeNode()
    cloned.Text = text
    cloned.Font.Bold = original.Font.Bold
    cloned.Font.Italic = original.Font.Italic
    cloned.ImageUrl = original.ImageUrl

    For Each node As RadTreeNode In original.Nodes
      cloned.Nodes.Add(CloneNode(node, original.Text))
    Next
    Return cloned
  End Function

  Protected Sub RadTreeViewEP_NodeEdit(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEditEventArgs) Handles RadTreeViewEP.NodeEdit
    Dim nodeEdited As RadTreeNode = e.Node
    Dim newText As String = e.Text

    nodeEdited.Text = newText
  End Sub

  Protected Sub RadTreeViewEP_NodeExpand(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs) Handles RadTreeViewEP.NodeExpand
    'SQL Database connection
    Dim sConnect As New SMARTCB.ConnectSMART.Connections
    Dim cn As New SqlConnection
    cn.ConnectionString = sConnect.GetConnectionString

    If e.Node.Level = 0 Then    'Get EP Indicator Topics (Functions)
      Dim myCMDf As New SqlDataAdapter
      Dim myCMf As New SqlCommand
      myCMf.Connection = cn
      myCMf.CommandType = CommandType.StoredProcedure
      myCMf.CommandText = "FuncSearchV4"

      Dim myParmF As New SqlParameter("@Key", SqlDbType.Int)

      myParmF.Value = e.Node.Value
      myParmF.Direction = ParameterDirection.Input
      myCMf.Parameters.Add(myParmF)

      myParmF = New SqlParameter("@SID", SqlDbType.VarChar)
      myParmF.Value = "1"
      myParmF.Direction = ParameterDirection.Input
      myCMf.Parameters.Add(myParmF)

      myParmF = New SqlParameter("@NH", SqlDbType.VarChar)
      myParmF.Value = "1"
      myParmF.Direction = ParameterDirection.Input
      myCMf.Parameters.Add(myParmF)

      myParmF = New SqlParameter("@SrchX", SqlDbType.VarChar)
      myParmF.Value = "0"
      myParmF.Direction = ParameterDirection.Input
      myCMf.Parameters.Add(myParmF)

      myCMDf.SelectCommand = myCMf

      Dim FUNC As DataSet = New DataSet
      myCMDf.Fill(FUNC, "dFunc")
      Dim mydatatablefunc As New DataTable
      mydatatablefunc = FUNC.Tables("dFunc")

      'myCMDf.Parameters.AddWithValue("parentId", e.Node.Value)
      'Dim adapter As New SqlDataAdapter(selectCommand)
      'Dim data As New DataTable()
      'adapter.Fill(data)

      Dim myRowF As DataRow
      Dim currRowsF() As DataRow = mydatatablefunc.Select(Nothing, Nothing, DataViewRowState.CurrentRows)
      For Each myRowF In currRowsF 'build new table for positioning skill topics
        Dim node As New RadTreeNode()
        node.Text = myRowF("bbfuncname")
        node.Value = myRowF("bbfuncId")
        node.ImageUrl = "../images/booksx.gif"
        node.Height = Unit.Pixel(22)
        node.ForeColor = Drawing.Color.FromName("#732928")
        node.Font.Size = "10"
        'If CInt(myRowF("ChildCount")) > 0 Then
        node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack
        'End If
        e.Node.Nodes.Add(node)
      Next
      e.Node.Expanded = True
    End If

    If e.Node.Level = 1 Then 'Get EP Indicator SubTopics (Categories)
      Dim myCMDc As New SqlDataAdapter
      Dim myCMc As New SqlCommand
      myCMc.Connection = cn
      myCMc.CommandType = CommandType.StoredProcedure
      myCMc.CommandText = "CatSearchV4"

      Dim myParmC As New SqlParameter("@Key", SqlDbType.Int)

      myParmC.Value = e.Node.Value
      myParmC.Direction = ParameterDirection.Input
      myCMc.Parameters.Add(myParmC)

      myParmC = New SqlParameter("@SID", SqlDbType.VarChar)
      myParmC.Value = "1"
      myParmC.Direction = ParameterDirection.Input
      myCMc.Parameters.Add(myParmC)

      myParmC = New SqlParameter("@NH", SqlDbType.VarChar)
      myParmC.Value = "1"
      myParmC.Direction = ParameterDirection.Input
      myCMc.Parameters.Add(myParmC)

      myParmC = New SqlParameter("@SrchX", SqlDbType.VarChar)
      myParmC.Value = "0"
      myParmC.Direction = ParameterDirection.Input
      myCMc.Parameters.Add(myParmC)

      myCMDc.SelectCommand = myCMc

      Dim CAT As DataSet = New DataSet
      myCMDc.Fill(CAT, "dCat")
      Dim mydatatablecat As New DataTable
      mydatatablecat = CAT.Tables("dCat")

      'myCMDf.Parameters.AddWithValue("parentId", e.Node.Value)
      'Dim adapter As New SqlDataAdapter(selectCommand)
      'Dim data As New DataTable()
      'adapter.Fill(data)

      Dim myRowC As DataRow
      Dim currRowsC() As DataRow = mydatatablecat.Select(Nothing, Nothing, DataViewRowState.CurrentRows)
      For Each myRowC In currRowsC 'build new table for positioning skill topics
        Dim node As New RadTreeNode()
        node.Text = myRowC("bbcatname")
        node.ImageUrl = "../images/books2x.gif"
        node.Height = Unit.Pixel(22)
        node.ForeColor = Drawing.Color.FromName("#732928")
        node.Font.Size = "9"
        node.Value = myRowC("bbcatId")
        'If CInt(myRowC("ChildCount")) > 0 Then
        node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack
        'End If
        e.Node.Nodes.Add(node)
      Next
      e.Node.Expanded = True
    End If

 

  End Sub

 

End Class

 

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 09 Mar 2009, 11:56 AM
Hi Scott,

Thank you for contacting us.

I am not able to reproduce the issue with the provided code, could you please open a support ticket and send us a running example illustrating the problem there? Thanks in advance.

Best wishes,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Scott MacDonald
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or