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

Bulk Update Exception

5 Answers 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 09 Aug 2012, 02:23 PM
Hello,

I'm using my own Collection Implementation and bind this to GridView 
public class BindingTypedList<T> : Collection<T>, INotifyCollectionChanged
{
    publicvoid AddRange(IList<T> items)
    {
        foreach(T item in items)
        {
            this.Add(item);
        }
        FireCollectionChanged(items);
    }
     
    public void FireCollectionChanged(IList<T> items)
    {
        try
        {
            if (CollectionChanged != null)
                CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, items.ToList()));
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
        }
    }
    public event NotifyCollectionChangedEventHandler CollectionChanged;
}
I have an exception in FireCollectionChanged Funktion:

---------------------------
Index must be within the bounds of the List.


Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)


   at System.Collections.Generic.List`1.Insert(Int32 index, T item)


   at Telerik.Windows.Data.KeyedCollection.Insert(Int32 index, Object value) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\KeyedCollection.cs:line 179


   at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1476


   at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1340


   at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1817


   at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1797


   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\WeakEvents\WeakEvent.cs:line 33


   at FileExplorer.ViewModel.BindingTypedList`1.FireCollectionChanged(IList`1 items) in D:\Y\IZTMediaContainer\IZTMediaLibrary\ViewModel\DirInfo.cs:line 65
---------------------------


Could you please help me.

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Aug 2012, 05:58 AM
Hello,

Similar to standard WPF components, RadGridView does not support NotifyCollectionChangedAction.Add with multiple items.

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Valerio
Top achievements
Rank 1
answered on 22 Jan 2015, 10:42 AM
Hi,
I'm having a similar issue trying to do the same, I subclassed the ObservableCollection to add an AddRange/RemoveRange operation for bulk insert/remove with optimized performance. Is this operation still not supported? Any plan to implement it in the near future?

Regards,
Valerio
0
Ivan Ivanov
Telerik team
answered on 22 Jan 2015, 12:16 PM
Hi,

With the current latest version, bulk add/remove operaions do not work with NotifyCollectionChangedAction.Add/NotifyCollectionChangedAction.Remove and this is a design concept we intend to follow in the future. Have you considered using RadObservableCollection<T>? It supports Suspend/Resume notifications, so that you can disable notifications before a bulk operation, preventing RadGridView from processing multiple event calls. When notifications are resumed NotifyCollectionChanged with reset action is raised.

Regards,
Ivan Ivanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Valerio
Top achievements
Rank 1
answered on 22 Jan 2015, 12:56 PM
Thanks Ivan,

I just tried it and it works as expected. Thank you for the quick answer!

Just for your reference, I was able to by-pass the problem by calling the CollectionChanged event using the NotifyCollectionChangedAction.Reset parameter instead of NotifyCollectionChangedAction.Add. In any case, it seems that the RadObservableCollection does what I need and therefore I will follow that path.

Regards,
Valerio
0
Ivan Ivanov
Telerik team
answered on 22 Jan 2015, 12:59 PM
Hi,

I am glad to hear that RadObservableColelction meets your requirements. I am closing the thread for now. Feel free to write back to us in case you need any further assistance.

Regards,
Ivan Ivanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Stefan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Valerio
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or