diff --git a/_contentTemplates/common/event-arguments.md b/_contentTemplates/common/event-arguments.md
new file mode 100644
index 0000000000..3f9669f2f3
--- /dev/null
+++ b/_contentTemplates/common/event-arguments.md
@@ -0,0 +1,31 @@
+#rowclick-args
+
+The event arguments expose an `EventArgs` property. It maps to `MouseEventArgs` or `KeyboardEventArgs` depending on the user's action (clicking the row with the mouse/tapping it on a touch device, or pressing `Enter` when the row is focused). You can use the event arguments to determine the keyboard key or the position of the mouse cursor when the user took an action.
+
+#end
+
+#rowclick-args-example
+
+ if (args.EventArgs is KeyboardEventArgs keyboardEventArgs)
+ {
+ Console.WriteLine($"The user clicked {keyboardEventArgs.Key} on row {model.Name}");
+ }
+ else if (args.EventArgs is MouseEventArgs mouseEventArgs)
+ {
+ Console.WriteLine($"The user clicked {mouseEventArgs.ClientX} {mouseEventArgs.ClientY} on row {model.Name}");
+ }
+
+#end
+
+#rowclick-args-treeview-example
+
+ if (args.EventArgs is KeyboardEventArgs keyboardEventArgs)
+ {
+ Console.WriteLine($"The user clicked {keyboardEventArgs.Key} on node {item.Text}");
+ }
+ else if (args.EventArgs is MouseEventArgs mouseEventArgs)
+ {
+ Console.WriteLine($"The user clicked {mouseEventArgs.ClientX} {mouseEventArgs.ClientY} on node {item.Text}");
+ }
+
+#end
\ No newline at end of file
diff --git a/_contentTemplates/grid/common-link.md b/_contentTemplates/grid/common-link.md
index 6e35a119c3..97a7672ca9 100644
--- a/_contentTemplates/grid/common-link.md
+++ b/_contentTemplates/grid/common-link.md
@@ -3,26 +3,6 @@
#end
-#rowclick-args
-
-The `GridRowClickEventArgs` class exposes an `EventArgs` property. It maps to `MouseEventArgs` or `KeyboardEventArgs` depending on the user's action (clicking the row with the mouse/tapping it on a touch device, or pressing `Enter` when the row is focused). You can use the event arguments to determine the keyboard key or the position of the mouse cursor when the user took an action.
-
-#end
-
-#rowclick-args-example
-
- if (args.EventArgs is KeyboardEventArgs keyboardEventArgs)
- {
- Console.WriteLine($"The user clicked {keyboardEventArgs.Key} on row {model.Name}");
- }
- else if (args.EventArgs is MouseEventArgs mouseEventArgs)
- {
- Console.WriteLine($"The user clicked {mouseEventArgs.ClientX} {mouseEventArgs.ClientY} on row {model.Name}");
- }
-
-#end
-
-
#conditional-style-row-and-cell-render
````CSHTML
@* Conditional styling/formatting for a cell and row *@
diff --git a/components/contextmenu/integration.md b/components/contextmenu/integration.md
index 66888ac719..0a475e0b2c 100644
--- a/components/contextmenu/integration.md
+++ b/components/contextmenu/integration.md
@@ -27,6 +27,7 @@ This article provides the following two examples:
* [Know The Target And Adjust Items](#know-the-target-and-adjust-items)
* [Context Menu for a Grid Row](#context-menu-for-a-grid-row)
+* [Context Menu for a TreeView Node](#context-menu-for-a-treeview-node)
You can apply the approach of hooking to your own events to show the context menu in other scenarios as well. For example, you can [add a context menu for your treeview nodes]({%slug contextmenu-kb-treeview-item%}).
@@ -37,11 +38,12 @@ Hooking to your own HTML elements' events lets you determine what to do with the
>caption Use the context menu target and change menu items based on the target data
````CSHTML
-@* Get context menu target and alter its items based on it *@
+@* Get context menu target and alter its items based on it *@
+ TextField="Text" SeparatorField="Separator" IconField="Icon"
+ DisabledField="Disabled"
+ OnClick="@( (ContextMenuItem itm) => ContextMenuClickHandler(itm) )">
@@ -77,7 +79,7 @@ Hooking to your own HTML elements' events lets you determine what to do with the
MenuItems[2].Items[0].Disabled = clickedItem.IsSpecial;
}
- async Task ClickHandler(ContextMenuItem clickedItem)
+ async Task ContextMenuClickHandler(ContextMenuItem clickedItem)
{
// handle the command from the context menu by using the stored metadata
if (!string.IsNullOrEmpty(clickedItem.CommandName) && LastClickedItem != null)
@@ -92,7 +94,7 @@ Hooking to your own HTML elements' events lets you determine what to do with the
{
MenuItems = new List()
- {
+ {
new ContextMenuItem
{
Text = "More Info",
@@ -107,7 +109,7 @@ Hooking to your own HTML elements' events lets you determine what to do with the
{
Text = "Advanced",
Items = new List()
- {
+ {
new ContextMenuItem
{
Text = "Delete",
@@ -171,8 +173,8 @@ Hooking to your own HTML elements' events lets you determine what to do with the
To integrate the context menu with the Telerik Grid, you need to:
-1. Use the grid's `OnRowContextMenu` event to get the current row model and show the menu
-2. Use the context menu's `OnClick` event to handle the desired operation
+1. Use the grid's [`OnRowContextMenu`]({%slug grid-events%}#onrowcontextmenu) event to get the current row model and show the menu
+2. Use the context menu's [`OnClick`]({%slug contextmenu-events%}#onclick) event to handle the desired operation
In this example, the context menu is used to select/deselect items, put an item in edit mode and delete items
@@ -182,7 +184,9 @@ In this example, the context menu is used to select/deselect items, put an item
@using System.Collections.Generic
@using System.Collections.ObjectModel
-
+
+()
- {
+ {
new MenuItem(){ Text = "Select", Icon="checkbox-checked", CommandName="ToggleSelect" },
new MenuItem(){ Text = "Edit", Icon="edit", CommandName="BeginEdit" },
new MenuItem(){ Text = "Delete", Icon="delete", Action = DeleteItem }
@@ -383,6 +387,200 @@ In this example, the context menu is used to select/deselect items, put an item
}
````
+## Context Menu for a TreeView Node
+
+To integrate the ContextMenu with the TreeView, you need to:
+
+1. Use the [`OnItemContextMenu`]({%slug treeview-events%}#onitemcontextmenu) event of the TreeView to get the current row model and show the menu
+2. Use the context menu's [`OnClick`]({%slug contextmenu-events%}#onclick) event to handle the desired operation
+
+In this example, the context menu is used to select/deselect items and delete items
+
+>caption Use a Context Menu for TreeView nodes
+
+````CSHTML
+@* Use the OnItemContextMenu event of the TreeView to show the ContextMenu for its items *@
+
+
+
+
+
+
+
+@code {
+ private TelerikContextMenu ContextMenu { get; set; }
+
+ public TreeItem LastClickedItem { get; set; }
+
+ public IEnumerable