In our program we have the possibility to select all records with CTRL + A. It can happen that more than 8000 records are selected.
To make sure that the records are really selected in the UI, we have to execute the code as follows...
foreach (var record in recordsToSelect) {
record.IsSelected = true;
}
This takes more than 17 seconds within the Infragistics environment.
Is there a way to optimize the selection and to reduce the execution time?
Hello Adrian,
The reason that the loop that you have provided is not performant is because it will select each record one-by-one, essentially raising the same number of selection notifications as the count of “recordsToSelect.”
Rather than doing this, I would recommend a couple of alternatives. First would be to utilize the AddRange method on the XamDataGrid.SelectedItems.Records collection and passing all of the records that you want to select as a Record[].
An alternative to this is to utilize the SelectedDataItems collection and put together an object[] containing all of the underlying data items that represent the records you want to select. These can be obtained from the DataItem property of each of the records. Note, you will also need to set the SelectedDataItemsScope property on the grid for this to update.
Please let me know if you have any other questions or concerns on this matter.
Hello Andrew,thank you so much for your quick response.I tried your first suggestion and it worked perfectly in our case.