Grid throwing json serialization errors when dataSource changes

I have the next grid. When the data is static, the grid works fine, no issues. But when the datasource is being refresh based on a external filter, it throws the error bellow. I already tried with Observable and just plain list and i get the same error. It is very frustrating :( 
<SfGrid @ref="@grid" 
DataSource="ObservableData"
TValue="Model"
AllowExcelExport="true"
AllowFiltering="false"
AllowPaging="true"
AllowResizing="true"
AllowSorting="true"
Height="100%"
Width="100%">
<GridPageSettings PageSize="20" PageSizes="new[] {20, 50, 100}"/>
<GridEvents OnLoad="@((x) => OnLoadGridHandler())" TValue="Model"></GridEvents>
<GridColumns>
<GridColumn
AllowResizing="false"
AllowEditing="false"
AllowFiltering="false"
AllowReordering="false"
AllowSorting="false"
AllowGrouping="false"
ShowInColumnChooser="false"
ShowColumnMenu="false"
Width="100px"
AllowSearching="false">
<Template>
@{
var chamber = (Model) context;
<div class="btn-group">
<a rel='nofollow' href="#" class="btn btn-sm warning orange" @onclick="@(() => { isLoading = true; NavigateToPage($"/chamber/{chamber.Id}/details");})">
<i class="fa fa-edit"></i>
</a>
</div>
}
</Template>
</GridColumn>
<GridColumn Field="ModelName" HeaderText="Model Name"/>
<GridColumn Field="@nameof(Model.ActiveStatus)" HeaderText="Status" Width="100px">
<Template>
@{
@if(context is Model chamber)
{
@if (chamber.IsEnabled)
{
<button class="btn btn-sm btn-success" @onclick="@(e => ToggleChamber(chamber.Id, chamber.IsEnabled))" style="cursor: pointer">
Disable
</button>
}
else
{
<button class="btn btn-sm btn-danger" @onclick="@(e => ToggleChamber(chamber.Id, chamber.IsEnabled))" style="cursor: pointer">
Enable
</button>
}
}
}
</Template>
</GridColumn>
<GridColumn Field="@nameof(Model.ActiveCampaignSubDomain)" HeaderText="Campaign Site" >
<Template>
@{
if (context is Model chamber)
{
if (!string.IsNullOrWhiteSpace(chamber.ActiveCampaignSubDomain))
{
<a rel='nofollow' href="@($"{chamber.ActiveCampaignSubDomain}.{AdminConfiguration.PrimaryDomainName}")" class="" target="_blank">
@chamber.ActiveCampaignName
</a>
}
}
}
</Template>
</GridColumn>
</GridColumns>
</SfGrid>

Error:
[2020-11-12T01:27:35.934Z] Error: System.Text.Json.JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 0.
   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_SerializerCycleDetected(Int32 maxDepth)
   at System.Text.Json.JsonSerializer.Write(Utf8JsonWriter writer, Int32 originalWriterDepth, Int32 flushThreshold, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.JsonSerializer.WriteCore(Utf8JsonWriter writer, Object value, Type type, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.WriteCore(PooledByteBufferWriter output, Object value, Type type, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.WriteCoreString(Object value, Type type, JsonSerializerOptions options)
   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.SfDataBoundComponent.UpdateProperty[T](String propertyName, T publicValue, T privateValue, Object eventCallback, Expression`1 expression)
   at Syncfusion.Blazor.Grids.SfGrid`1.OnHybridParametersSet()
   at Syncfusion.Blazor.Grids.SfGrid`1.OnParametersSetAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)


5 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team November 12, 2020 09:42 AM UTC

Hi Ernesto,  
 
Thanks for contacting Syncfusion support.  
 
Query: “But when the datasource is being refresh based on a external filter, it throws the error bellow. 
 
We have analyzed the reported query and stack trace of the issue at our end. We have faced the reported issues in our older version of Syncfusion.Blazor. We have resolved this issue in our 18.3.0.38 version patch release. If you are using lower version Syncfusion.Blazor, kindly upgrade to our latest version to resolve the reported issue.  
 
Kindly get back to us with more detail about your Syncfusion.Blazor version, if you are still facing the reported issue in latest version. Also ensure to update your .Net Version to 5.0  
 
Regards, 
Vignesh Natarajan 
 



SE Seetha January 20, 2021 03:20 AM UTC

Hi,

I am also facing similar exception while using SFGrid.

Exception: System.Text.Json.JsonException: A possible object cycle was detected. 
This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles.

I've also attached complete error description with this thread.

Other details:
Syncfusion version: 18.3.0.47

Please assist. 

Thanks

Attachment: StockDiagramHistory_c257f129.zip


VN Vignesh Natarajan Syncfusion Team January 20, 2021 07:56 AM UTC

Hi Seetha,  

Thanks for contacting Syncfusion support.  

Query: “I am also facing similar exception while using SFGrid. 

We have analyzed the query and we understand that you are facing the circular reference issue while binding the data to SfGrid. As mentioned we have faced the reported issue in our older version Syncfusion.Blazor Nuget package. Kindly ensure the reported issue by upgrading the application (Syncfusion.Blazor nuget) to our latest version.  

If you are still facing the reported issue, kindly share the following details.  

  1. Share your .Net Core version.
  2. Are you facing the reported issue during the initial rendering itself or during a certain action.
  3. If possible share the issue reproducible sample.

Above requested details will be helpful for us to validate the reported issue query at our end and provide solution as early as possible.         
  
Regards, 
Vignesh Natarajan 



SE Seetha replied to Vignesh Natarajan January 21, 2021 08:19 PM UTC

Hi Seetha,  

Thanks for contacting Syncfusion support.  

Query: “I am also facing similar exception while using SFGrid. 

We have analyzed the query and we understand that you are facing the circular reference issue while binding the data to SfGrid. As mentioned we have faced the reported issue in our older version Syncfusion.Blazor Nuget package. Kindly ensure the reported issue by upgrading the application (Syncfusion.Blazor nuget) to our latest version.  

If you are still facing the reported issue, kindly share the following details.  

  1. Share your .Net Core version.
  2. Are you facing the reported issue during the initial rendering itself or during a certain action.
  3. If possible share the issue reproducible sample.

Above requested details will be helpful for us to validate the reported issue query at our end and provide solution as early as possible.         
  
Regards, 
Vignesh Natarajan 


Hi Viki,

Thanks for your response.

  1. Share your .Net Core version. --> .NET core 3.1
  2. Are you facing the reported issue during the initial rendering itself or during a certain action. --> Initial rendering is ok but just after any action on the screen throws an error.
  3. If possible share the issue reproducible sample. Will check and revert.

We used Breeze.sharp one of the class object to retrieve information from database which directly assigned to grid as data source that led to the exception. .We got some workaround solution by just removing the inheritance of BaseEntity which worked for us. 

using System;
using Breeze.Sharp;

namespace xx.xxx.Dto.Db
    public class UnitTrackingHistory : BaseEntity
    {
          -----
           -----
     }
}

In short, all set. Thanks for your quick act/response

Many thanks

Marked as answer

VN Vignesh Natarajan Syncfusion Team January 22, 2021 03:25 AM UTC

Hi Seetha,  

Thanks for the update.  

We are glad to hear that you have resolved your query on your own.  

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon