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

Cannot clear unwanted select bottom node!

2 Answers 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
nfigueroa
Top achievements
Rank 1
nfigueroa asked on 17 Oct 2013, 07:54 PM
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()
    da.Fill(dt)
    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
        nodes.Add(tn)
        PopulateNodes(tn.Nodes, dr("ItemID"))
    Next
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" />
</asp:Panel>

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 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 22 Oct 2013, 08:05 AM
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?
 

Regards,
Bozhidar
Telerik
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.
0
nfigueroa
Top achievements
Rank 1
answered on 23 Oct 2013, 08:46 PM
Alexey

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!
Tags
TreeView
Asked by
nfigueroa
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
nfigueroa
Top achievements
Rank 1
Share this question
or