How to set both default and Custom Context menu items in the Blazor DataGrid?

Answer:

We can use the default context menu and custom context menu in the Blazor DataGrid by using the code snippet below.

<SfGrid @ref="Grid" ID="Grid" DataSource="@OrderData" AllowPaging="true" ContextMenuItems="@ContextMenuItems">

..

..

SfGrid>

@code{

private List<object> ContextMenuItems = new List<object>()

{ "Autofit", "AutoFitAll", "SortAscending", "SortDescending", "Copy", "Edit", "Delete", "Save", "Cancel",

"PdfExport", "ExcelExport", "CsvExport", "FirstPage", "PrevPage", "LastPage", "NextPage",

new ContextMenuItemModel

{

Text = "Show", Id = "Show"

},

new ContextMenuItemModel

{

Text = "Give to players", Id = "GiveToPlayers"

}

};

}


Please find the sample to set both the default and custom context menu in Blazor DataGrid here.


Loader.
Up arrow icon