-
Notifications
You must be signed in to change notification settings - Fork 2
Context menu - Readme update #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
cfb0d95
39b71f2
938645a
980c0db
5fdd48a
f7e40f5
0533099
464e501
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,21 +5,54 @@ | |||||
| [](#does-this-example-address-your-development-requirementsobjectives) | ||||||
| <!-- default badges end --> | ||||||
|
|
||||||
| # Blazor Grid - Display a Context Menu | ||||||
| # Blazor Grid - Customize Context Menu | ||||||
|
|
||||||
| You can display a Context Menu when you right-click any Blazor Grid element. In this example, a click on a column header or row invokes the Context Menu. | ||||||
| This repository displays for various DxGrid areas, customizes their items using DxGrid's built-in APIs, and defines context menus for areas that do not include built-in context menus. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| Add the **oncontextmenu:preventDefault** to disable the standard browser context menu. In the Grid's [CustomizeElement](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.CustomizeElement) event handler, subscribe to the **contextmenu** event (displays the custom Context Menu). | ||||||
| ## Implementation Details | ||||||
|
|
||||||
| The [GridContextMenuContainer](./CS/GridWithContextMenu/Pages/GridContextMenuContainer.razor) component contains Context Menu components. The [GridContextMenuHelper](./CS/GridWithContextMenu/Data/GridContextMenuHelper.cs) class implements Context Menu's item generation, manages state, and includes the click handlers that use the Blazor [Grid's API](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid._methods) to execute commands. | ||||||
| ### Display Context Menus for All Built-in Areas | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| Set the [ContextMenus](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.ContextMenus) property to `All` to enable DxGrid built-in context menus for the following areas: Header, Footer, Data Row, Group Panel, Group Row, and Group Footer. | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| File to Review: [Index.razor](./CS/GridWithContextMenu/Pages/Index.razor#L14) | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| ### Customize Context Menu Items Using Grid's Built-in API | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| DxGrid Component includes built-in APIs to customize context menu items. Follow the steps below to implement them: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original phrase is ambiguous: do we implement APIs or context menu items?
Suggested change
|
||||||
|
|
||||||
| 1. Add the [oncontextmenu:preventDefault](./CS/GridWithContextMenu/Pages/Index.razor#L14) to disable the standard browser context menu. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step is not required at this point. This is for the next section (see notes form Alex in the support card). |
||||||
| 2. In the Grid's [CustomizeContextMenu](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.CustomizeContextMenu) event handler, subscribe to the **contextmenu** event to display the custom context menu items. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which custom items? Provide some details. We can also mention the helper class here. |
||||||
|
|
||||||
| This scenario affects the following DxGrid areas: Header, Footer, and Data Rows. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can mention this in the section intro. |
||||||
|
|
||||||
| Files to Review: | ||||||
| * [Index.razor](./CS/GridWithContextMenu/Pages/Index.razor#L64) | ||||||
| * [GridContextMenuHelper.cs](./CS/GridWithContextMenu/Data/GridContextMenuHelper.cs#L298-L365) | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| ### Add Custom Context Menus | ||||||
|
|
||||||
| The [GridContextMenuContainer](./CS/GridWithContextMenu/Pages/GridContextMenuContainer.razor) component contains Context Menu components. The [GridContextMenuHelper](./CS/GridWithContextMenu/Data/GridContextMenuHelper.cs) class implements Context Menu's item generation, manages state, and includes the click handlers that use the Blazor [Grid's API](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid._methods) to execute commands. Follow the steps below to display custom context menus: | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| 1. Add the [oncontextmenu:preventDefault](./CS/GridWithContextMenu/Pages/Index.razor#L14) to disable the standard browser context menu. | ||||||
| 2. In the Grid's [CustomizeElement](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.CustomizeElement) event handler, subscribe to the **contextmenu** event to display the custom Context Menu. | ||||||
|
|
||||||
| This scenario affects the following application areas: Toolbar Component, DxGrid's Edit Row, and DxGrid's Pager. | ||||||
|
|
||||||
|
|
||||||
| Files to Review: | ||||||
| * [Index.razor](./CS/GridWithContextMenu/Pages/Index.razor#L66) | ||||||
| * [GridContextMenuContainer.razor](./CS/GridWithContextMenu/Pages/GridContextMenuContainer.razor#L4-L28) | ||||||
| * [GridContextMenuHelper.cs](./CS/GridWithContextMenu/Data/GridContextMenuHelper.cs#L31-59) | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| <!-- | ||||||
|
friedcucumber marked this conversation as resolved.
Outdated
|
||||||
| ## Files to Review | ||||||
|
|
||||||
| - [Index.razor](./CS/GridWithContextMenu/Pages/Index.razor) | ||||||
| - [GridContextMenuHelper.cs](./CS/GridWithContextMenu/Data/GridContextMenuHelper.cs) | ||||||
| - [GridContextMenuContainer.razor](./CS/GridWithContextMenu/Pages/GridContextMenuContainer.razor) | ||||||
| - [GridContextMenuContainer.razor](./CS/GridWithContextMenu/Pages/GridContextMenuContainer.razor) --> | ||||||
|
|
||||||
| ## Documentation | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.