This is a migrated thread and some comments may be shown as answers.

Deleting Large Number of Items Issue

2 Answers 15 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 07 Mar 2016, 06:33 AM

Hi,

I have a grid view bound to a RadObservableCollection that contains around a million items. when I select all items and delete them from the grid view (using telerik:RadGridViewCommands.Delete), the whole application freezes and stops responding. I tried all the tricks and tips for optimizing the grid view, but that didn't help.

How do I solve the issue?

Thanks

2 Answers, 1 is accepted

Sort by
0
Ahmed
Top achievements
Rank 1
answered on 07 Mar 2016, 06:41 AM
Note: The issue happens only when the number of selected items is large.
0
Stefan Nenchev
Telerik team
answered on 08 Mar 2016, 12:28 PM
Hello Ahmed,

I am adding my reply to your ticket in this forum thread as well.

Indeed, deleting 1 000 000 records from the RadGridView takes a large amount of time to complete. As you are using RadObservableCollection as ItemsSource, you can get the benefits of its AddRange method as when it is applied all notifications to the RadGridView are suspended and thus the performance is boosted:

private void RadButton_Click_1(object sender, RoutedEventArgs e)
        {
            var items = this.DataParametersGridView.ItemsSource asRadObservableCollection<DataParameter>;
            var itemsToRemove = new ObservableCollection<DataParameter>();
            foreach (DataParameter item inthis.DataParametersGridView.SelectedItems)
            {
                itemsToRemove.Add(item);
            }
            items.RemoveRange(itemsToRemove);
        }

The aforementioned approach decreases the time for the items deletion. Still, as 1 000 000 items is a pretty huge number, there is some significant period of waiting. If you need to clear all the items from the collection, I suggest you use its Clear method directly:

(this.DataParametersGridView.ItemsSource as RadObservableCollection<DataParameter>).Clear();


Regards,
Stefan Nenchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Ahmed
Top achievements
Rank 1
Stefan Nenchev
Telerik team
Share this question
or