2 posts, 0 answers
  1. Kjell
    Kjell avatar
    212 posts
    Member since:
    May 2011

    Posted 30 Jan 2013 Link to this post

    This works great except e.Node.Selected = False
    I try disable that you can click (select) on node 1 and 2, but it may not function?
    Help me :-)
    Protected Sub RadTreeView1_NodeDataBound(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs)
        e.Node.ToolTip = (TryCast(e.Node.DataItem, DataRowView))("NodeId").ToString() & " + " & (TryCast(e.Node.DataItem, DataRowView))("ParentNodeId").ToString()
        e.Node.ImageUrl = "../images/caTree/" & (TryCast(e.Node.DataItem, DataRowView))("ImageUrl").ToString()
        e.Node.NavigateUrl = "../admin_dbpage.aspx?id=" & (TryCast(e.Node.DataItem, DataRowView))("NodeId").ToString() & "&db=ledare" & "&url=ledare/"
        e.Node.Target = "main"
        If (TryCast(e.Node.DataItem, DataRowView))("NodeId").ToString() = 1 Or (TryCast(e.Node.DataItem, DataRowView))("NodeId").ToString() = 2 Then
            e.Node.AllowDrag = False
            e.Node.Selected = False
        End If
    End Sub
  2. Kate
    Kate avatar
    1898 posts

    Posted 01 Feb 2013 Link to this post

    Hi Kjell,

    The selected property of a node can be used in a scenario when you need to have a specific node selected/not selected. I tested the scenario and once you set the selected to false, the node does not get selected on page load. However, as I understand from your scenario you are trying to make the node not selectable. You can use the AllowDrag property of a node if you need to disable the dragging of a specific node of the Enable="false" if you need to disable the node.   Another approach is to cancel the selection and the clicking of the specific node using the client-side approach with the OnClientNodeClicking event:
    <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="WebBlue" OnClientNodeClicking="OnClientNodeClicking" OnNodeDataBound="RadTreeView1_NodeDataBound" EnableDragAndDrop="true">

    function OnClientNodeClicking(sender, args) {
                      if (args.get_node().get_text() == "nameOfTheNode")
                         //cancel the click event
                          //prevents selection of a node

    the Telerik team
    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 their blog feed now.
Back to Top