You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
4
+
5
+
#end
6
+
7
+
#rowclick-args-example
8
+
9
+
if (args.EventArgs is KeyboardEventArgs keyboardEventArgs)
10
+
{
11
+
Console.WriteLine($"The user clicked {keyboardEventArgs.Key} on row {model.Name}");
12
+
}
13
+
else if (args.EventArgs is MouseEventArgs mouseEventArgs)
14
+
{
15
+
Console.WriteLine($"The user clicked {mouseEventArgs.ClientX} {mouseEventArgs.ClientY} on row {model.Name}");
16
+
}
17
+
18
+
#end
19
+
20
+
#rowclick-args-treeview-example
21
+
22
+
if (args.EventArgs is KeyboardEventArgs keyboardEventArgs)
23
+
{
24
+
Console.WriteLine($"The user clicked {keyboardEventArgs.Key} on node {item.Text}");
25
+
}
26
+
else if (args.EventArgs is MouseEventArgs mouseEventArgs)
27
+
{
28
+
Console.WriteLine($"The user clicked {mouseEventArgs.ClientX} {mouseEventArgs.ClientY} on node {item.Text}");
Copy file name to clipboardExpand all lines: _contentTemplates/grid/common-link.md
-20Lines changed: 0 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,6 @@
3
3
#end
4
4
5
5
6
-
#rowclick-args
7
-
8
-
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.
9
-
10
-
#end
11
-
12
-
#rowclick-args-example
13
-
14
-
if (args.EventArgs is KeyboardEventArgs keyboardEventArgs)
15
-
{
16
-
Console.WriteLine($"The user clicked {keyboardEventArgs.Key} on row {model.Name}");
17
-
}
18
-
else if (args.EventArgs is MouseEventArgs mouseEventArgs)
19
-
{
20
-
Console.WriteLine($"The user clicked {mouseEventArgs.ClientX} {mouseEventArgs.ClientY} on row {model.Name}");
21
-
}
22
-
23
-
#end
24
-
25
-
26
6
#conditional-style-row-and-cell-render
27
7
````CSHTML
28
8
@* Conditional styling/formatting for a cell and row *@
@@ -27,6 +27,7 @@ This article provides the following two examples:
27
27
28
28
*[Know The Target And Adjust Items](#know-the-target-and-adjust-items)
29
29
*[Context Menu for a Grid Row](#context-menu-for-a-grid-row)
30
+
*[Context Menu for a TreeView Node](#context-menu-for-a-treeview-node)
30
31
31
32
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%}).
32
33
@@ -37,11 +38,12 @@ Hooking to your own HTML elements' events lets you determine what to do with the
37
38
>caption Use the context menu target and change menu items based on the target data
38
39
39
40
````CSHTML
40
-
@* Get context menu target and alter its items based on it *@
41
+
@* Get context menu target and alter its items based on it *@
0 commit comments