Percentage calculation - add item to observable collection - NullReferenceException

My PivotGridControl is bound to a ObservableCollection

In a GUI thread (triggered by ` System.Windows.Threading .DispatcherTimer`),  I add items to the  ObservableCollection.

Configured PivotTable with a percentage SubCount / ParentCount, I got an NullReferenceException as below:


```

 at Syncfusion.PivotAnalysis.Base.PivotEngineUpdatingManager.ChangeValue(Object oldValue, Object newValue, Object item, String propertyName, Int32 row, Int32 col, Boolean adjustAdd, Boolean adjustRemove)

   at Syncfusion.PivotAnalysis.Base.PivotEngineUpdatingManager.OnItemAdded(Object item)

   at Syncfusion.PivotAnalysis.Base.PivotEngineUpdatingManager.UpdateRefreshHelper_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)

   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)

   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)

   at UpdatingDemo.Form1.timer_Tick(Object sender, EventArgs e) in C:\yi\pivotgrid\Interactive Features\Updating Demo\CS\Form1.cs:line 226

   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

   at System.Windows.Threading.DispatcherOperation.InvokeImpl()

   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Windows.Threading.DispatcherOperation.Invoke()

   at System.Windows.Threading.Dispatcher.ProcessQueue()

   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)

   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)

   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

   at UpdatingDemo.Program.Main() in C:\yi\pivotgrid\Interactive Features\Updating Demo\CS\Program.cs:line 27

```


So, percentage  calculation does not  allow adding new item to the bound collection.

I attached also the my testing project.  NullRefException.png in the zip is the percentage configuration of the pivot grid.


The problem can be reproduced by clicking on 'Add at Top', 'Add at middle' or 'Add at bottom' buttons

  Can you please suggest? 


Attachment: CS__Copy_f2435364.7z

1 Reply

SS Sampathnarayanan Sankaralingam Syncfusion Team February 4, 2022 12:29 PM UTC

Hi Yi Han,


We are unable to replicate the issue in the sample you have provided. We have checked with the latest Nuget version and checked the issue but couldn’t get any issue from our side and working as expected. Please refer the video from the below link.


Video Link : https://www.syncfusion.com/downloads/support/forum/172542/ze/SampleVideo15164502


If you are still facing the issue, please revert to us with the Syncfusion version you are using in your end.


Regards,

Sampath Narayanan.S


Loader.
Up arrow icon