Cannot clear unwanted select bottom node!

3 posts, 0 answers
  1. nfigueroa
    nfigueroa avatar
    21 posts
    Member since:
    Apr 2010

    Posted 17 Oct 2013 Link to this post

    Dear all

    For some strange reason the RadTreeView will not allow me to deselect the bottom node (as seen in picture).  I have tried to programmatically select the node and even setting a SelectedCssClass with transparent as background color and still the same result.  If any other node is clicked the selection reverts back to the same one.

    I load the nodes programmatically using the following code ...
    Private Sub PopulateNodes(ByVal nodes As Telerik.Web.UI.RadTreeNodeCollection, Optional parentid As Integer = Nothing)
        Dim objConn As New SqlConnection(Application("dbRO"))
        Dim tConn As New SqlConnection(Application("db"))
        Dim objCommand As New SqlCommand("SELECT ItemID,ItemDescription,ItemURL,ImageURL FROM tblROMenuItems sc WHERE Visible=1 ORDER BY ItemOrder", "ItemParent=@ParentID AND Visible=1 ORDER BY ItemOrder,ItemOrder2,ItemOrder3,ItemOrder4"), objConn)
        If Not (parentid = 0) Then objCommand.Parameters.Add("@ParentID", SqlDbType.Int).Value = parentid
        Dim da As New SqlDataAdapter(objCommand)
        Dim dt As New DataTable()
        For Each dr As DataRow In dt.Rows
            Dim tn As New RadTreeNode
            Select Case dr("ItemID").ToString
                Case "52" 'separation lines
                    tn.Enabled = False 'tn.SelectAction = TreeNodeSelectAction.None
            End Select
            tn.Value = dr("ItemID").ToString
            tn.ImageUrl = dr("ImageURL").ToString
            tn.Text = dr("ItemDescription").ToString
            tn.CssClass = IIf(parentid = 0, "rootNode", "childNode")
            tn.Target = dr("ItemURL").ToString
            PopulateNodes(tn.Nodes, dr("ItemID"))
    End Sub

    and the aspx call for the control
    <asp:Panel BorderStyle="None" CssClass="Menu" HorizontalAlign="Left" ID="pnlModules" runat="server" ScrollBars="Auto" style="background-size: 100%; left: 0; position: relative; top: 0; width: 100%">
        <telerik:RadTreeView BorderStyle="None" ExpandAnimation-Duration="200" ID="TreeView1" RenderMode="Lightweight" runat="server" SelectedCssClass="selectedNode" ShowLineImages="False" SingleExpandPath="True" Width="100%" MaxDataBindDepth="10" />

    After this code executes then I have tried the TreeView1.SelectedNodes.Clear() .  Nothing works!

    Any help with this matter would be most appreciated!

    Neftali Figueroa
    System Analyst
  2. Bozhidar
    Bozhidar avatar
    1146 posts

    Posted 22 Oct 2013 Link to this post

    Hi Neftali,

    This is an odd issue, that we are unable to replicate locally. Could you open a support ticket and attach a simplified runnable sample project that reproduces the issue, along with steps to reproduce it?

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. nfigueroa
    nfigueroa avatar
    21 posts
    Member since:
    Apr 2010

    Posted 23 Oct 2013 Link to this post


    Thanks for the reply.  I partially solved the problem by using CSS to override the behavior.  I was able to take off the selected background color and hovering the same with

            .RadTreeView .rtUL .rtLI .rtSelected .rtIn { color: inherit; background: none !important }

    Then I found in the code the instruction 
    If TreeView1.Nodes.Count > 0 Then TreeView1.Nodes(TreeView1.Nodes.Count - 1).Selected = True

    which caused the undesired behavior.  I thought I revised all the code prior to creating this post! Mistake on my part.

    Hope the CSS helps someone with a similar situation!
Back to Top