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

NodeExpand event is providing the wrong node value when using NodeTemplate

1 Answer 47 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mikhail
Top achievements
Rank 1
Mikhail asked on 05 Jul 2012, 07:52 PM
Hello!

I am using  Telerik version: 2009.3.1208.0

My task is to add an arrow to the node (on the right side of the node) so people can left-click on it and access context menu. See picture attached.

I was able to to do that through creating a nodetemplate (subscribing to an interface) and then assigning my class to NodeTemplate property (on Page Init) 

Here is the code:

Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Telerik.Web.UI
 
    Public Class MyNodeTemplate
        Implements ITemplate
 
        Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
            Dim newLabel As New Label()
            newLabel.CssClass = "nodeLabel"
            newLabel.Text = DirectCast(container, RadTreeNode).Text
 
            Dim arrowDiv As New System.Web.UI.HtmlControls.HtmlGenericControl("DIV")
            arrowDiv.Attributes.Add("class", "nodeRightClickArrow")
            arrowDiv.Attributes.Add("onclick", "LeftClickContextMenuClick(event, this);")
 
            container.Controls.Add(newLabel)
            container.Controls.Add(arrowDiv)
        End Sub
 
    End Class

Everything seems fine EXCEPT:

When expanding one of the nodes, the NodeExpand Event sends the wrong value for the node that is being expanded. For example, if I expand Node 3, it gives me value (e.Node.Value)  for Node 1. See attached picture for more explanation. As a result wrong child nodes are loaded.


Questions:

1) Why NodeExpand is broken when NodeTemplate is being added ?
2) Any way to achieve  adding an arrow to the node so people can left-click on it without overwriting NodeTemplate?

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 10 Jul 2012, 11:51 AM
Hello Makhail,

 
I tested the issue and it worked properly at my side with the latest version of our controls so it may be a bug that have been fixed. I am attaching my test project. You can also consider the second way of using templates that is described in the bottom part of this help article.

Hope this will be helpful.

Regards,
Plamen
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.
Tags
TreeView
Asked by
Mikhail
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or