5 Answers, 1 is accepted
0
Hello Bruce,
By default, you can use the Edited, NodeAdded, and NodeRemoved events to handle the respective operations.
If you want to override the default actions you need to modify the default context menu and add new custom items: Modifying the Default Context Menu.
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
By default, you can use the Edited, NodeAdded, and NodeRemoved events to handle the respective operations.
If you want to override the default actions you need to modify the default context menu and add new custom items: Modifying the Default Context Menu.
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Bruce
Top achievements
Rank 2
answered on 16 Aug 2017, 04:15 PM
I'm sorry if I was unclear, Those events seemingly are fired whenever a node is effected, regardless if this action was originated by the context menu, or if a node is added programmatically.
I am trying to identify the origin of the event firing, specifically when it is done in the context menu.
For example, when the user right clicks, and uses the context menu to add a new node, I want to trigger the edit method on the new node so they can directly edit it. This behavior would be proper when the nodes are being added via a datasource or programmatically.
0
Hi Bruce,
You cannot override the new behavior but you can replace the default item and use custom logic. Here is an example for this:
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Progress Telerik
You cannot override the new behavior but you can replace the default item and use custom logic. Here is an example for this:
private
void
RadTreeView1_ContextMenuOpening(
object
sender, Telerik.WinControls.UI.TreeViewContextMenuOpeningEventArgs e
{
for
(
int
i = e.Menu.Items.Count - 1; i >= 0; i--)
{
if
(e.Menu.Items[i].Name ==
"New"
)
{
e.Menu.Items.Remove(e.Menu.Items[i]);
var newItem =
new
RadMenuItem(
"Add Node"
);
newItem.Click += NewItem_Click;
e.Menu.Items.Insert(i, newItem);
break
;
}
}
}
private
void
NewItem_Click(
object
sender, EventArgs e)
{
var newNode =
new
RadTreeNode(
"New Node"
);
RadTreeNode node =
this
.radTreeView1.SelectedNode;
if
(node ==
null
)
{
return
;
}
node.Nodes.Add(newNode);
node.Expanded =
true
;
this
.radTreeView1.SelectedNode = newNode;
this
.radTreeView1.BeginEdit();
}
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Bruce
Top achievements
Rank 2
answered on 17 Aug 2017, 02:39 PM
Is there a way to detect when a node is added from the context menu as opposed to any other method?
0
Hello Bruce,
No there is no built-in way to determine this. Perhaps you can use a flag when updating the tree view from your code:
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
No there is no built-in way to determine this. Perhaps you can use a flag when updating the tree view from your code:
bool
addingIncode =
false
;
private
void
button1_Click(
object
sender, EventArgs e)
{
addingIncode =
true
;
radTreeView1.Nodes.Add(
"Test"
);
addingIncode =
false
;
}
private
void
RadTreeView1_NodeAdded(
object
sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
{
if
(addingIncode)
{
return
;
}
}
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.