In v19.2, we introduced a new API to bind the DxDataGrid component to data asynchronously. The previous synchronous version of the OptimizedMultipleSelectionChanged event would not work with asynchronous data binding. For this reason, we made this event asynchronous and no longer support the synchronous version.
The event's signature has been updated as follows:
Old:
Codepublic Action<DataGridSelection<T>> OptimizedMultipleSelectionChanged { get; set; }
New:
Codepublic Func<DataGridSelection<T>, Task> OptimizedMultipleSelectionChanged { get; set; }
The SelectedKeys and SelectedKeysMatchingFilter properties of the DataGridSelection class have also become asynchronous.
Old:
Codepublic IEnumerable<object> SelectedKeys { get; }
public IEnumerable<object> SelectedKeysMatchingFilter { get; }
New:
Codepublic Task<IEnumerable<object>> SelectedKeys { get; }
public Task<IEnumerable<object>> SelectedKeysMatchingFilter { get; }
If you handled the OptimizedMultipleSelectionChanged event, update the handler implementation similarly to the code below.
Old:
Code<DxDataGrid Data="@DataSource"
KeyFieldName="Id"
SelectionMode="DataGridSelectionMode.OptimizedMultipleSelection"
OptimizedMultipleSelectionChanged="OnSelectionChanged">
...
</DxDataGrid>
@code {
protected void OnSelectionChanged(DataGridSelection<ProductFlat> selection)
{
...
var selectedCount = selection.SelectedKeys.Count();
...
}
}
New:
Code<DxDataGrid Data="@DataSource"
KeyFieldName="Id"
SelectionMode="DataGridSelectionMode.OptimizedMultipleSelection"
OptimizedMultipleSelectionChanged="OnSelectionChanged">
...
</DxDataGrid>
@code {
protected async Task OnSelectionChanged(DataGridSelection<ProductFlat> selection)
{
...
var selectedKeys = await selection.SelectedKeys;
var selectedCount = selectedKeys.Count();
...
}
}