This is a migrated thread and some comments may be shown as answers.
Hide/disable node
3 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 24 Feb 2019, 09:57 PM

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

3 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 27 Feb 2019, 12:18 PM
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.
0
Kjell
Top achievements
Rank 1
answered on 27 Feb 2019, 11:00 PM

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
0
Peter Milchev
Telerik team
answered on 04 Mar 2019, 04:48 PM
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.
Asked by
Kjell
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or