Hide/disable node

4 posts, 0 answers
  1. Kjell
    Kjell avatar
    225 posts
    Member since:
    May 2011

    Posted 24 Feb 2019 Link to this post

    How can I disable RadDropDownTree node based on nodeid?

    I want to disable the first and second node in the tree based on the database nodeid 1 and 2

  2. Peter Milchev
    Admin
    Peter Milchev avatar
    899 posts

    Posted 27 Feb 2019 Link to this post

    Hello Kjell,

    You can programmatically subscribe to the OnNodeDataBound event of the embedded TreeView and set the Enabled property based on the node's data item: 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadDropDownTree1.EmbeddedTree.NodeDataBound += EmbeddedTree_NodeDataBound;
            // other code here ...
        }
    }

    private void EmbeddedTree_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
        // use data item data instead
        if (e.Node.Text == "World Continents")
        {
            e.Node.Enabled = false;
        }
    }


    Regards,
    Peter Milchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Kjell
    Kjell avatar
    225 posts
    Member since:
    May 2011

    Posted 27 Feb 2019 in reply to Peter Milchev Link to this post

    Is not that example for telerik:RadTreeView?

    I use telerik:RadDropDownTree

    Protected Sub RadDropDownTree1_NodeDataBound(sender As Object, e As Telerik.Web.UI.DropDownTreeNodeDataBoundEventArguments)
     
    End Sub
  4. Peter Milchev
    Admin
    Peter Milchev avatar
    899 posts

    Posted 04 Mar 2019 Link to this post

    Hello Kjell,

    Yes, the article is for the TreeView but the DropDownTree uses the TreeView control to show the tree in the dropdown. Also, the NodeDataBound of the DropDownTree does not have the properties as the TreeView's node and that is why I suggest adding the handler for the embedded TreeView's event.

    For VB, you can use the following code to attach the handler in the Page_Load event:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            AddHandler RadDropDownTree1.EmbeddedTree.NodeDataBound, AddressOf EmbeddedTree_NodeDataBound
        End If
    End Sub
     
    Private Sub EmbeddedTree_NodeDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)
        If e.Node.Text = "World Continents" Then
            e.Node.Enabled = False
        End If
    End Sub

    Regards,
    Peter Milchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top