6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 07 Oct 2013, 11:58 AM
Hi Sonia,
In RadTreeView, OnNodeClick event is used to capture selected node change on server side and OnClientNodeClicked is used to achieve the same via client side. Please check the following help documentations.
NodeClick
OnClientNodeClicked
Thanks,
Shinu.
In RadTreeView, OnNodeClick event is used to capture selected node change on server side and OnClientNodeClicked is used to achieve the same via client side. Please check the following help documentations.
NodeClick
OnClientNodeClicked
Thanks,
Shinu.
0
Sonia
Top achievements
Rank 1
answered on 07 Oct 2013, 12:33 PM
OnNodeClick is not fire if the selection is made in code behind, and this is the scenario i need to solve!!
Please, any idea?
Please, any idea?
0
Hi Sonia,
I tested the following demo and it seems that the event of the RadTreeView control fires as expected - TreeView - Server-side Events. Please give it a try and let me know how it goes from your side.
Regards,
Kate
Telerik
I tested the following demo and it seems that the event of the RadTreeView control fires as expected - TreeView - Server-side Events. Please give it a try and let me know how it goes from your side.
Regards,
Kate
Telerik
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 the blog feed now.
0
Sonia
Top achievements
Rank 1
answered on 08 Oct 2013, 09:30 AM
That demo does not demostrate the scenario i was trying to explain.
See the lines of code below, when i select newTreeNode, OnNodeClick is not fired, however OnSelectedNodeChanged would have fired.
RadTreeNode newTreeNode =
new
RadTreeNode(name, id);
RadTreeView1.Nodes.Add(newTreeNode);
newTreeNode.Selected =
true
;
0
Hi Sonia,
Can you please provide the markup code and the code behind that you are using so I can get a better understanding of the scenario that you currently get?
Regards,
Kate
Telerik
Can you please provide the markup code and the code behind that you are using so I can get a better understanding of the scenario that you currently get?
Regards,
Kate
Telerik
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 the blog feed now.
0
Shinu
Top achievements
Rank 2
answered on 17 Oct 2013, 11:52 AM
Hi Sonia,
Please have a look into the following full code I tried for your scenario.
ASPX:
C#:
JavaScript:
In the above code after creating the RadNode from sever side, I am calling a script "nodeClick". In the script I am accessing the node which is added from server side and then selecting it which in turn fire the OnNodeClick server side event.
Thanks,
Shinu.
Please have a look into the following full code I tried for your scenario.
ASPX:
<
telerik:RadTreeView
ID
=
"RadTreeView1"
runat
=
"server"
OnNodeClick
=
"RadTreeView1_NodeClick"
>
<
Nodes
>
<
telerik:RadTreeNode
runat
=
"server"
Text
=
"Node 1"
>
</
telerik:RadTreeNode
>
<
telerik:RadTreeNode
runat
=
"server"
Text
=
"Node 2"
>
</
telerik:RadTreeNode
>
</
Nodes
>
</
telerik:RadTreeView
>
<
br
/>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Add Node"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
C#:
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
string
nodeText =
"Node 3"
;
string
nodeValue =
"3"
;
RadTreeNode newTreeNode =
new
RadTreeNode(nodeText, nodeValue);
RadTreeView1.Nodes.Add(newTreeNode);
string
script =
"function f(){nodeClick('"
+ nodeText +
"'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
;
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"key"
, script,
true
);
}
protected
void
RadTreeView1_NodeClick(
object
sender, RadTreeNodeEventArgs e)
{
Response.Write(
"<script>alert('Node Clicked')</script>"
);
}
JavaScript:
<script type=
"text/javascript"
>
function
nodeClick(arg) {
var
radtreeview = $find(
'<%=RadTreeView1.ClientID %>'
);
radtreeview.findNodeByText(arg).select();
}
</script>
In the above code after creating the RadNode from sever side, I am calling a script "nodeClick". In the script I am accessing the node which is added from server side and then selecting it which in turn fire the OnNodeClick server side event.
Thanks,
Shinu.