New to Telerik UI for .NET MAUI? Start a free 30-day trial

.NET MAUI DataGrid Events

The Telerik UI for .NET MAUI DataGrid component exposes a set of events which help users achieve seamless and effective experience when interacting with the component.

Loading Content on Demand

The load-on-demand feature gets implemented through the LoadOnDemand event. The LoadOnDemand event handler receives the following parameters:

  • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
  • A LoadOnDemandEventArgs object, which provides the IsDataLoaded (bool) property, indicating whether the data is loaded.

For more information, see the topic about loading data on demand in the .NET MAUI DataGrid.

The following example demonstrates how to use the LoadOnDemand event.

1. Define the LoadOnDemand method in XAML.

2. Create the method that defines the functionality of the event.

private void dataGrid_LoadOnDemand(object sender, Telerik.Maui.Controls.Compatibility.DataGrid.LoadOnDemandEventArgs e)
{
    for (int i = 0; i < 15; i++)
    {
        ((sender as RadDataGrid).ItemsSource as ObservableCollection<Person>).Add(new Person() { Name = "Person " + i, Age = i + 18, Gender = i % 2 == 0 ? Gender.Male : Gender.Female });
    }
    e.IsDataLoaded = true;
}

Loading Distinct Values

The DataGrid enables you to load the distinct values that will be displayed in the Telerik.Maui.Controls.Compatibility.DataGrid.DataGridDistinctValuesFilterView through the DistinctValuesLoading event. The DistinctValuesLoading event handler receives the following parameters:

  • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
  • A DistinctValuesLoadingEventArgs object, which provides the following properties:
    • DistinctValues—Specifies a list of values of type IEnumerable which are to be displayed in the DataGridDistinctValuesFilterView.
    • (Read-only) Column of type DataGridColumn—Gets the column for which the distinct values are being loaded.

For more information, see the topic about the available filtering options in the .NET MAUI DataGrid.

Binding to Data

The DataGrid also provides the DataBindingComplete event which occurs when the associated DataGrid ItemsSource has been successfully bound to the control, or when any data operation like grouping, sorting, or filtering is applied. The DataBindingComplete event handler receives the following parameters:

  • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
  • A DataBindingCompleteEventArgs object, which provides the DataView (IDataViewCollection) property and allows for traversing and/or manipulating the already computed data view.

Modifying Group Selections

The DataGrid delivers the SelectionChanged event which is triggered whenever the SelectedItems collection is changed. The SelectionChanged event handler receives the following parameters:

  • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
  • A DataGridSelectionChangedEventArgs object, which provides the following properties:
    • RemovedItems—Gets a list of the removed items from the SelectedItems collection.
    • AddedItems—Gets a list of the added items to the SelectedItems collection.

For more information, see the article about the SelectionChanged event of the .NET MAUI DataGrid.

Changing the Current Cell

The DataGrid also supports the CurrentCellChanged event which is invoked when the current cell changes. The CurrentCellChanged event handler receives the following parameters:

  • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
  • A CurrentCellChangedEventArgs object, which provides the following properties:
    • OldCurrentCell—Gets the previously CurrentCell.
    • NewCurrentCell—Gets the new CurrentCell.

For more information, see the article about the CurrentCellChanged event in the .NET MAUI DataGrid.

Additional Resources

See Also

In this article