.NET MAUI DataGrid Commands
The command design-pattern is very important and widely used in the XAML and MVVM world. The Telerik UI for .NET MAUI DataGrid strictly follows these best practices and provides an intuitive and an easy-to-use set of APIs that allow different aspects of the DataGrid behavior to be handled and/or completely overridden.
The DataGrid exposes a Commands
collection that allows you to register custom commands with each control instance through the RadDataGrid.Commands
property:
The Commands is part of Telerik UI for .NET MAUI, the most comprehensive UI suite for .NET MAUI! To try it out, sign up for a free 30-day trial and kickstart your cross-platform app development today.
-
Commands
—Gets the collection with all the custom commands registered with theCommandService
. Custom commands have higher priority than the built-in (default) ones.
Command Types
-
DataGridCommand
—All the default commands withinRadDataGrid
derive from the baseDataGridCommand
. Think of this command as a UI-related command as it operates over theRadDataGrid
instance that owns the command.-
Id
—The key that relates a command instance to a particular action/routine. This value is used to associate a command with a known event within aRadDataGrid
instance. -
Command
—Gets or sets the genericICommand
implementation that may come from theViewModel
. -
EnableDefaultCommand
—Gets or sets a value indicating whether the default (built-in) UI command associated with the specifiedId
will be executed. The default value isTrue
.
-
DataGridCommandId Enumeration
All the predefined commands within a RadDataGrid
instance are identified by a member of the DataGridCommandId
enumeration. This is actually the key that relates a command instance to a particular action/routine within the owning grid. To register a custom command within a RadDataGrid
instance, you can inherit the DataGridCommand
class and override its CanExecute
and Execute
methods. You need to set the Id
property of the new command so that it can be properly associated with the desired action/event. Following are the members of the DataGridCommandId
enumerations.
The table below shows all commands in the DataGrid control and for each of the available commands there is an object which is passed as a parameter
in its Execute
method.
Commands | Object type |
---|---|
Unknown | DataGridColumn |
ColumnHeaderTap |
DataGridTextColumn |
GroupHeaderTap |
GroupHeaderContext |
GroupHeaderButtonTap |
GroupHeaderContext |
CellTap |
DataGridCellInfo |
CellDoubleTap |
DataGridCellInfo |
GenerateColumn |
GenerateColumnContext |
DataBindingComplete |
DataBindingCompleteEventArgs |
BeginEdit |
EditContext |
CancelEdit |
EditContext |
CommitEdit |
EditContext |
ValidateCell |
ValidateCellContext |
LoadMoreData |
LoadOnDemandContext |
FilterTap |
FilterTapContext |
ApplyFilter |
FilterTapContext |
CloseFilter |
FilterTapContext |
ResetFilter |
FilterTapContext |
KeyDown |
KeyboardInfo |
ToggleRowDetailsButtonTap |
the type is the data model |
For an outline of all DataGrid features review the .NET MAUI DataGrid Overview article.