How to update Pivot Table with source data refreshed

Hi, 

I am trying to refresh the pivot table by periodically refresh its data source. It's certainly not the correct way to proceed... Can you please suggest.?


Expected Behavior:

After the timer call back is called, I am expecting the pivot table content automatically updated.


Many thanks,

Yi


Attachment: RefreshPivotTable_85143998.zip

14 Replies

MM Manikandan Murugesan Syncfusion Team February 7, 2022 12:42 PM UTC

Hi Yi Han, 
 
Currently we are analyzing this at our end, and we will update further details within two business days (February 9, 2022). 

Regards, 
Manikandan 



YH Yi Han February 9, 2022 08:51 PM UTC

Hi,

My requirement is to let users construct dynamically pivot table on a changing data updated in timely fashion.

Two questions here, please:

1/ In blazor server architecture, the your component loads all data to browser and it's up to javascript to build pivot table, or you build the pivoted result on server side, then send back to browser?

2/ purely for the mentioned feature, in terms of performance, do you recommend blazor server architecture or the one of web assembly? Please note that I have large dataset - 500k lines

Thanks!

Yi



YH Yi Han February 9, 2022 09:18 PM UTC

Hi,


I updated my app that you can find in the attached zip file.


The app scales well to 20_000 lines.


It goes wrong with 200_000 lines, data refreshed every 5 seconds with initial wait of 5 seconds.

The applicaiton crashed at the very beginning:


```log

Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.

Microsoft.Hosting.Lifetime: Information: Hosting environment: Development

Microsoft.Hosting.Lifetime: Information: Content root path: C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application

index page 52974372

Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll

There is no region associated with the Invariant Culture (Culture ID: 0x7F).


removed 16439

removed 9428

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in Microsoft.AspNetCore.Components.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in Microsoft.AspNetCore.Components.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in Microsoft.AspNetCore.Components.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in Microsoft.AspNetCore.Components.dll

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware: Error: An unhandled exception has occurred while executing the request.


System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

   at System.Collections.Generic.List`1.Enumerator.MoveNext()

   at System.Text.Json.Serialization.Converters.IEnumerableDefaultConverter`2.OnWriteResume(Utf8JsonWriter writer, TCollection value, JsonSerializerOptions options, WriteStack& state)

   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter writer, TCollection value, JsonSerializerOptions options, WriteStack& state)

   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)

   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)

   at System.Text.Json.JsonSerializer.WriteUsingSerializer[TValue](Utf8JsonWriter writer, TValue& value, JsonTypeInfo jsonTypeInfo)

   at System.Text.Json.JsonSerializer.WriteStringUsingSerializer[TValue](TValue& value, JsonTypeInfo jsonTypeInfo)

   at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)

   at Syncfusion.Blazor.Internal.SfBaseUtils.Equals[T](T oldValue, T newValue)

   at Syncfusion.Blazor.SfBaseComponent.NotifyPropertyChanges[T](String propertyName, T publicValue, T privateValue, Boolean updatePrevProps)

   at Syncfusion.Blazor.SfBaseComponent.NotifyPropertyChanges[T](String propertyName, T publicValue, T privateValue)

   at Syncfusion.Blazor.PivotView.PivotViewDataSourceSettings`1.ParametersSet()

   at Syncfusion.Blazor.PivotView.PivotViewDataSourceSettings`1.OnParametersSetAsync()

   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.HandleExceptionViaErrorBoundary(Exception error, ComponentState errorSourceOrNull)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToPendingTasks(Task task, ComponentState owningComponentState)

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)

   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessPendingRender()

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)

   at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()

   at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()

   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.HandleExceptionViaErrorBoundary(Exception error, ComponentState errorSourceOrNull)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToPendingTasks(Task task, ComponentState owningComponentState)

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(Int32 componentId, ParameterView initialParameters)

   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.CreateInitialRenderAsync(Type componentType, ParameterView initialParameters)

   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.RenderComponentAsync(Type componentType, ParameterView initialParameters)

   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c__11`1.<<InvokeAsync>b__11_0>d.MoveNext()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer.PrerenderComponentAsync(ParameterView parameters, HttpContext httpContext, Type componentType)

   at Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.PrerenderedServerComponentAsync(HttpContext context, ServerComponentInvocationSequence invocationId, Type type, ParameterView parametersCollection)

   at Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.RenderComponentAsync(ViewContext viewContext, Type componentType, RenderMode renderMode, Object parameters)

   at Microsoft.AspNetCore.Mvc.TagHelpers.ComponentTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)

   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count)

   at MyBlazorServerApp.Pages.Pages__Host.<ExecuteAsync>b__14_1() in C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application\Pages\_Host.cshtml:line 21

   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()

   at MyBlazorServerApp.Pages.Pages__Host.ExecuteAsync() in C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application\Pages\_Host.cshtml:line 5

   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)

   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)

   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)

   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)

   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Exception thrown: 'System.NullReferenceException' in Microsoft.AspNetCore.Components.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in Microsoft.AspNetCore.Components.dll

added 30842

removed 3009

added 43155

```



data refreshed every 10 seconds with about 200_000 lines, NullReferenceException and the pivot table is not updating.


```log

Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.

Microsoft.Hosting.Lifetime: Information: Hosting environment: Development

Microsoft.Hosting.Lifetime: Information: Content root path: C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application

index page 32282393

Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll

index page 37933309

Exception thrown: 'System.IndexOutOfRangeException' in Syncfusion.Licensing.dll

added 35202

Exception thrown: 'System.NullReferenceException' in Syncfusion.Blazor.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

removed 13803

Exception thrown: 'System.NullReferenceException' in Syncfusion.Blazor.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

added 49740

Exception thrown: 'System.NullReferenceException' in Syncfusion.Blazor.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll

```


Please suggest.


Thanks


Yi


Attachment: CreateaPivotTableinaBlazorServerApplication__Copy_c6d59c7f.zip


MM Manikandan Murugesan Syncfusion Team February 10, 2022 04:09 PM UTC

Hi Yi Han, 
 
Please find the response below. 
Query 
Comments 
In blazor server architecture, your component loads all data to browser and it's up to javascript to build pivot table, or you build the pivoted result on server side, then send back to browser? 
In Blazor server, all operations are performed on the server side, and only the elements to be rendered to the browser are returned via the SignalR connection. Please see the following document for more information on the blazor server mode. 
 
 
purely for the mentioned feature, in terms of performance, do you recommend blazor server architecture or the one of web assembly? Please note that I have large dataset - 500k lines 
The Blazor server mode application performs better than the WASM. To render the application with a larger data source, please use the Blazor server application with virtualization. Please see the following UG document for more information on the virtualization option. 
 
 
It goes wrong with 200_000 lines, data refreshed every 5 seconds with initial wait of 5 seconds. 
The application crashed at the very beginning: 
The pivot table processes and summarizes raw data before displaying it in tabular format. In general, the more data takes longer time to process the aggregation of the pivot table values. When we have a large number of unique row and column headers, we can improve performance by using the "Virtualization" option. If we have fewer unique headers with larger amount of data, it will take time to process, since virtualization works by slicing the large number of unique row and column headers alone. As a result, to avoid this problem, you should increase the interval time. Please take the following steps to improve the performance of the pivot table. 
 
Code Example: 
[Index.razor] 
<SfPivotView @ref="PivotTable" TValue="ProductDetails" EnableVirtualization="true"> 
</SfPivotView> 
 
[PollingService.cs] 
private const int TimerIntervalSecond = 10; 
 
To avoid the server disconnection problem, please add the following code to the "Startup.cs" file. 
Code Example: 
        public void ConfigureServices(IServiceCollection services) 
        { 
            services.AddSignalR(e => 
            { 
                e.MaximumReceiveMessageSize = 102400000; 
            }); 
            services.AddSyncfusionBlazor(); 
        } 

Meanwhile, we have modified your sample for your reference. Please find it from below link. 
 
 

Please let us know if you have any concerns. 

Regards, 
Manikandan 



YH Yi Han February 13, 2022 09:57 PM UTC

Hi Manikandan,

Thanks for your help.

What do you mean by " unique row and column headers " ?


Another problem that I can't understand:

When I open 2 (or N) browser pages, only the last opened page's data get refreshed. Do you have any explaination? Please suggest.

Many thanks,

Yi



MM Manikandan Murugesan Syncfusion Team February 14, 2022 04:09 PM UTC

Hi Yi Han, 
  
Please find the response below. 
Query 
Comments 
What do you mean by " unique row and column headers ”? 
The unique row and column headers in the pivot table refer to the unique values in the total data source for the fields bound to the row and column axes, respectively. Please see the screenshot below. 
  
Screenshot: 
 
When I open 2 (or N) browser pages, only the last opened page's data get refreshed. Do you have any explanation? Please suggest. 
Currently we are analyzing this at our end, and we will update further details within two business days (February 16, 2022). 
  
Please let us know if you have any concerns. 
  
Regards, 
Manikandan 



MM Manikandan Murugesan Syncfusion Team February 16, 2022 03:25 PM UTC

Hi Yi Han, 
 
Yes. This problem occurred because you unregistered all previous instances before registering the new one in the "OnInitializedAsync" method. Please remove the highlighted line below to resolve the reported issue at your end. 
 
Code Example: 
    protected override async Task OnInitializedAsync() 
    { 
        Debug.WriteLine($"index page {GetHashCode()}"); 
 
        await base.OnInitializedAsync(); 
        this.Data = PollingService.Instance.Observable; 
 
        if (!registered) 
        { 
            //PollingService.Instance.UnRegisterAll(); 
            PollingService.Instance.Register(GetHashCode(), UpdateData); 
            registered = true; 
        } 
 
        //_timer = new Timer(UpdateData, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5)); 
    } 
 
Please let us know if you have any concerns. 
 
Regards, 
Manikandan 



YH Yi Han February 16, 2022 06:51 PM UTC

Hi, 


Thanks for you reply!


Regarding this comment of mine:

> 2 (or N) browser pages, only the last opened page's data get refreshed. Do you have any explanation? Please suggest. 

Please ignore this interrogation, the cause is completed in my code.


Thanks,

Yi



YH Yi Han February 19, 2022 07:28 PM UTC

Hi,


With your last proposed source code, when I navigate from "Home" to "Counter" page, or reversely, I have this exception:

```

System.InvalidOperationException

  HResult=0x80131509

  Message=Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.

  Source=System.Private.CoreLib

  StackTrace:

   at System.ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported()

   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

   at Syncfusion.Blazor.Internal.SfBaseUtils.UpdateDictionary(String key, Object data, Dictionary`2 dictionary)

   at Syncfusion.Blazor.SfBaseComponent.ObservablePropertyChanged(Object sender, PropertyChangedEventArgs e)

   at MyBlazorServerApp.Pages.ProductDetails.NotifyPropertyChanged(String propertyName) in C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application\Pages\ProductDetails.cs:line 127

   at MyBlazorServerApp.Pages.ProductDetails.set_Year(String value) in C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application\Pages\ProductDetails.cs:line 41

   at MyBlazorServerApp.Pages.ProductDetails.WithValue(ProductDetails pd) in C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application\Pages\ProductDetails.cs:line 113

   at MyBlazorServerApp.Pages.PollingService.Refresh(Object state) in C:\yi\blazor\Create-a-Pivot-Table-in-a-Blazor-Server-Application\Pages\PollingService.cs:line 59

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

--- End of stack trace from previous location ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool)

   at System.Threading.TimerQueue.FireNextTimers()


  This exception was originally thrown at this call stack:

    System.ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported()

    System.Collections.Generic.Dictionary<TKey, TValue>.TryInsert(TKey, TValue, System.Collections.Generic.InsertionBehavior)

    Syncfusion.Blazor.Internal.SfBaseUtils.UpdateDictionary(string, object, System.Collections.Generic.Dictionary<string, object>)

    Syncfusion.Blazor.SfBaseComponent.ObservablePropertyChanged(object, System.ComponentModel.PropertyChangedEventArgs)

    MyBlazorServerApp.Pages.ProductDetails.NotifyPropertyChanged(string) in ProductDetails.cs

    MyBlazorServerApp.Pages.ProductDetails.Year.set(string) in ProductDetails.cs

    MyBlazorServerApp.Pages.ProductDetails.WithValue(MyBlazorServerApp.Pages.ProductDetails) in ProductDetails.cs

    MyBlazorServerApp.Pages.PollingService.Refresh(object) in PollingService.cs

    System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, object)

    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

    ...

    [Call Stack Truncated]

```

So, it seems that syncfusion uses a plain Dictionary (does not support concurrency) when ObservablePropertyChanged:

```

   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

   at Syncfusion.Blazor.Internal.SfBaseUtils.UpdateDictionary(String key, Object data, Dictionary`2 dictionary)

```


What is the thread safe way to update the Pivot table when the underlying data source is constantly changing? 

Many thanks,


Yi


Attachment: CreateaPivotTableinaBlazorServerApplication__Copy_(2)_2a82c9bd.zip


MM Manikandan Murugesan Syncfusion Team February 21, 2022 05:47 PM UTC

Hi Yi Han, 
 
This problem occurs when we attempt to update the data source while the pivot table is being updated. So, please hold off on updating the data source using the "EnginePopulated" event until the pivot table refresh is complete. Kindly refer to the following UG document to know more details about the "EnginePopulated" event. 
 
 
Please let us know if you have any concerns. 
 
Regards, 
Manikandan. 



YH Yi Han February 24, 2022 05:29 PM UTC

Hi Manikandan, 

I appreciate your reply. This really helps! :)




MM Manikandan Murugesan Syncfusion Team February 25, 2022 06:38 AM UTC

Hi Yi Han, 
 
Please let us know if you have any other queries. We are always happy to assist you. 
 
Regards, 
Manikandan 



YH Yi Han March 1, 2022 02:15 PM UTC

Hi,


Does it exist a way to be notified when I open the field list dialog and when a close (apply/cancel) it ?


The reason why I want to be notified is that my pivot table data is periodically refreshed (say every 2 seconds). When I open the field list dialog, it keeps blinking, which makes it impossible to do filed drag and drop.

My plan is to stop refreshing the data source of pivot view when I open the field list dialog and restart refreshing one I close it.

fieldlist_open.png

fieldlist_close.png

Is this the correct way to achieve the purpose?






MM Manikandan Murugesan Syncfusion Team March 2, 2022 07:11 PM UTC

Hi Yi Han, 
 
We don't have direct event support for detecting field list popup open and close actions right now. However, you can detect those actions by using "Interop JS". Please see the code example below. 
Code Example: 
[index.razor]: 
    private async void DataBound(Object args) 
    { 
        if (IsInit) 
        { 
            IsInit = false; 
            // To call javascript method. 
            await jsRuntime.InvokeVoidAsync("dataBound"); 
        } 
    } 
    [JSInvokable] 
    public static void FieldListOpen() 
    { 
        // This will be triggered when field list popup open. 
    } 
 
    [JSInvokable] 
    public static void FieldListClose() 
    { 
        // This will be triggered when field list popup closed. 
    } 
 
[PivotScript.js]: 
function dataBound() { 
    document.querySelector(".e-toggle-field-list").addEventListener("click", fieldListClick); 
    document.querySelector(".e-defer-cancel-button").addEventListener("click", fieldListCloseClick); 
} 
 
function fieldListClick() { 
    DotNet.invokeMethodAsync('PivotDemo', 'FieldListOpen'); 
} 
 
function fieldListCloseClick() { 
    DotNet.invokeMethodAsync('PivotDemo', 'FieldListClose'); 
} 
 
[_Host.cshtml]: 
<script src="scripts/PivotScript.js"></script> 
 
Meanwhile, we have prepared a sample for your reference. Please find it from below link. 

Please refer to the following document to know more details about the “Interop JS”. 
 
Please let us know if you have any concerns. 
 
Regards, 
Manikandan 


Loader.
Up arrow icon