I've found out (the hard way) that NodeClick event is not raised when the page containing the treeview has EnableViewState = false.
Is this a bug? I think it migth be since other events like NodeDataBound and ContextMenuItemClick are raise normally.
Thanks,
Martín
5 Answers, 1 is accepted
Please find attached an example which demonstrates how to use RadTreeView with disabled view state.
All the best,
Albert
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thanks for your example, it surely works but I when I link the tree to an AccessDataSource (try tree.mdb from the examples) that the problem appears. I will gladly upload an example app showing this if needed.
Thanks,
Martín
Indeed when binding to declarative sources RadTreeView will not raise the NodeClick event. This occurs due to the way declarative databinding works. It occurs later than the moment when postback events are processed and as a result the treeview is still empty. To force earlier databinding you should call the DataBind method of the treeview during the PageLoad event:
protected void Page_Load(object sender, EventArgs e)
{
RadTreeView1.DataBind();
}
Regards,
Albert
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I have the same problem . i would like to put EnableViewState=false to my RadTreeView but the onNodeEdit event does not raised.
My RadTreeView is loaded manually on Server side during Page_Load.
When a node has been edited, I would like to use the onNodeEdit event , to update some data and then load the RadTreeView . Here is a sample code to explain my scenario:
<telerik:RadTreeView ID="TreeViewFolder" runat="server" EnableViewState="false" Skin="Outlook" AllowNodeEditing="true" OnNodeEdit="TreeViewFolder_NodeEdit">
</telerik:RadTreeView>
Code-Behind (VB.NET) :
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
TreeViewBuild()
End If
End Sub
Sub TreeViewBuild()
Dim nodeMailBox As RadTreeNode
nodeMailBox =
New RadTreeNode("aaaa")
TreeViewFolder.Nodes.Add(nodeMailBox)
nodeMailBox =
New RadTreeNode("bbbb")
TreeViewFolder.Nodes.Add(nodeMailBox)
TreeViewFolder.DataBind()
End Sub
Protected Sub TreeViewFolder_NodeEdit(ByVal sender As Object, ByVal e As RadTreeNodeEditEventArgs)
Dim nodeEdited As RadTreeNode = e.Node
Dim newText As String = e.Text
TreeViewBuild()
End Sub
This code runs fine if EnableViewState=true (except the RadTreeView is duplicated)
Any idea?
Thanks for your help
Regards,
Frank Quinty
You should populate the treeview on every page load because you have disabled the viewstate. Just always call the TreeViewBuild method in Page_Load.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.