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

.NET MAUI DataGrid Events

The DataGrid component exposes a set of events.

  • LoadOnDemand— Occurs when the load on demand is requested. The LoadOnDemand event handler receives two parameters:
    • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
    • A LoadOnDemandEventArgs object, which provides the following property:
      • IsDataLoaded(bool)— Indicating whether the data is loaded.

For more information about LoadOnDemand event review the DataGrid LoadOnDemand article.

  • DistinctValuesLoading—Occurs when loading the distinct values that will be displayed in the Telerik.Maui.Controls.Compatibility.DataGrid.DataGridDistinctValuesFilterView. The DistinctValuesLoading event handler receives two 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— Is a property which specifies a list of values of type IEnumerable which are to be displayed in the DataGridDistinctValuesFilterView.
      • Column— Is a readonly property of type DataGridColumn which gets the column for which the distinct values are being loaded.

For more information about Filtering options in DataGrid review the DataGrid Filtering article.

  • DataBindingComplete—Occurs when the associated DataGrid data(ItemsSource) has been successfully bound to the control or any data operation like Group, Sort or filter is applied.

    • The sender argument, which is of type object, but can be cast to the RadDataGrid type.
    • A DataBindingCompleteEventArgs object, which provides the following property:
      • DataView(IDataViewCollection)—Implementation that allows for traversing and/or manipulating the already computed data view.
  • SelectionChanged event is triggered whenever the SelectedItems collection is changed. The SelectionChanged event handler receives two 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 about SelectionChanged event review the DataGrid Selection article.

  • CurrentCellChanged event is invoked when the current cell changes. The CurrentCellChanged event handler receives two 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 about CurrentCellChanged event review the DataGrid Current Cell article.

Example

The following example demonstrates the usage of the LoadOnDemand event.

Define the LoadOnDemand method in XAML:

Create the method defining 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;
}

See Also

In this article
Not finding the help you need?