ColumnHeaderTap Command
The ColumnHeaderTap
command handles the tap gesture over a column header. The default implementation of this command will try to add a new SortDescriptor
to the SortDescriptors
collection of the DataGrid thus changing the current sorting of the data.
Execution Parameter
The execution parameter is of type ColumnHeaderTapContext
and exposes the following properties:
-
Column
—Gets or sets theDataGridColumn
instance when the header is tapped. -
CanSort
—Determines whether the user is allowed to sort the data through the UI (as specified by theRadDataGrid.UserSortMode
property). -
IsMultipleSortAllowed
—Determines whether any existing sort will be cleared before new sort is applied (if any).
Custom ColumnHeaderTap Command
The following examples show how to create a class that inherits from the DataGridCommand
and then add it to the Commands
collection.
Create a Custom ColumnHeaderTap Command
public class CustomColumnHeaderTapCommand : DataGridCommand
{
public CustomColumnHeaderTapCommand()
{
this.Id = CommandId.ColumnHeaderTap;
}
public override bool CanExecute(object parameter)
{
var context = parameter as ColumnHeaderTapContext;
// put your custom logic here
return true;
}
public override void Execute(object parameter)
{
var context = parameter as ColumnHeaderTapContext;
// put your custom logic here
this.Owner.CommandService.ExecuteDefaultCommand(CommandId.ColumnHeaderTap, context);
}
}
Add the Custom Command to the Commands Collection
<Grid xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid">
<grid:RadDataGrid Width="600" Height="460" x:Name="grid">
<grid:RadDataGrid.Commands>
<local:CustomColumnHeaderTapCommand/>
</grid:RadDataGrid.Commands>
</grid:RadDataGrid>
</Grid>