.NET MAUI DataGrid Events
The DataGrid component exposes a set of events.
-
LoadOnDemand
— Occurs when the load on demand is requested. TheLoadOnDemand
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.
-
- The sender argument, which is of type object, but can be cast to the
For more information about LoadOnDemand event review the DataGrid LoadOnDemand article.
-
DistinctValuesLoading
—Occurs when loading the distinct values that will be displayed in theTelerik.Maui.Controls.Compatibility.DataGrid.DataGridDistinctValuesFilterView
. TheDistinctValuesLoading
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 typeIEnumerable
which are to be displayed in theDataGridDistinctValuesFilterView
. -
Column
— Is a readonly property of typeDataGridColumn
which gets the column for which the distinct values are being loaded.
-
- The sender argument, which is of type object, but can be cast to the
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.
-
- The sender argument, which is of type object, but can be cast to the
-
SelectionChanged
event is triggered whenever theSelectedItems
collection is changed. TheSelectionChanged
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 theSelectedItems
collection. -
AddedItems
—Gets a list of the added items to theSelectedItems
collection.
-
- The sender argument, which is of type object, but can be cast to the
For more information about SelectionChanged
event review the DataGrid Selection article.
-
CurrentCellChanged
event is invoked when the current cell changes. TheCurrentCellChanged
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 previouslyCurrentCell
. -
NewCurrentCell
—Gets the newCurrentCell
.
-
- The sender argument, which is of type object, but can be cast to the
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;
}