IContextMenuItemCollection.Flatten() Method
Converts the item collection into a flattened collection that contains all root-level and nested items of the context menu.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
NuGet Package: DevExpress.Blazor
Declaration
IEnumerable<IContextMenuItem> Flatten()
Returns
| Type | Description |
|---|---|
| IEnumerable<IContextMenuItem> | The flattened collection of all menu items. |
Remarks
Handle the CustomizeContextMenu event to modify context commands available in the Grid, Rich Text Editor, or TreeList component. In the event handler, call the Flatten method to recursively iterate through the item collection and obtain both root-level and nested items.
Note
Built-in Grid and TreeList context menu commands do not contain nested items. You can add them using Add or AddCustomItem methods.
The following code snippet removes icons for all items in the context menu (including sub-menus):
<DxRichEdit CustomizeContextMenu=OnCustomizeContextMenu/>
@code {
void OnCustomizeContextMenu(IContextMenuItemCollection items) {
foreach (var item in items.Flatten()) {
item.IconUrl = string.Empty;
}
}
}
Refer to CustomizeContextMenu event descriptions for additional information and examples: