Hi,
I'm having almost exact same problem as this previous thread https://www.syncfusion.com/forums/161874/odatav4-binding-with-embedded-object which was attributed to a problem with binding to ExpandoObject, and apparently resolved.
Using current version (19.4.0.42). The following code:
<SfTreeGrid TValue="OrgUnit" IdMapping="Id" ParentIdMapping="ParentId" HasChildMapping="HasChild" TreeColumnIndex="0">
<SfDataManager @ref="dm" Url="odata/OrgUnits" Adaptor="Adaptors.ODataV4Adaptor" />
<TreeGridEditSettings AllowEditing="true"/>
<TreeGridColumns>
<TreeGridColumn Field="@nameof(ou.Name)" />
<TreeGridColumn Field="@nameof(ou.Type)" Width="80" />
<TreeGridColumn Field="@nameof(ou.Id)" HeaderText="Id" Width="80" TextAlign="TextAlign.Right" IsPrimaryKey="true"/>
<TreeGridColumn Field="@nameof(ou.Acronym)" Width="80" />
<TreeGridColumn Field="@nameof(ou.AcronymPath)" HeaderText="Path1" Width="140" />
</TreeGridColumns>
</SfTreeGrid>
Generates error (then loops generating this error about 500/sec):
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: 'A' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
System.Text.Json.JsonException: 'A' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: 'A' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.Serialization.JsonConverter`1[[System.Byte[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter`1[[System.Byte[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.JsonConverter`1[[System.Byte[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at Syncfusion.Blazor.Internal.SfBaseUtils.ChangeType(Object dataValue, Type conversionType, Boolean isClientChange, Boolean isParseValue)
at Syncfusion.Blazor.TreeGrid.Internal.TreeGridutils`1[[Sirrus.Shared.OrgUnit, Sirrus.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetEventArgsData(Object treeData, String childMapping, Type dataType, SfTreeGrid`1 parent)
at Syncfusion.Blazor.TreeGrid.Internal.TreeGridutils`1[[Sirrus.Shared.OrgUnit, Sirrus.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ConvertToTreeGridArgs(Object gridArgs, Object treeGridArgs, SfTreeGrid`1 parent)
at Syncfusion.Blazor.TreeGrid.Internal.GridRenderer`1.<RowDataBoundHandler>d__65[[Sirrus.Shared.OrgUnit, Sirrus.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Syncfusion.Blazor.Grids.Internal.GridRowBase`1.<OnParametersSetAsync>d__70[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
I'm not using ExpandoObject. My datasource (odata/Orgunits) is just a self referencing dataset that includes Id, ParentId and HasChild.
If I retrieve the odata separately & supply same to SfTreeGrid, works OK. Just if I use SfDataManager to ODataV4 it fails.
Please advise.
Hi Farveen,
public class OrgUnit2 {
public OrgUnit2() { }
public int Id { get; set; }
public byte[] SysTS { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public int GlSetClient { get; set; }
public int GlSetAdmin { get; set; }
public int TemplateSet { get; set; }
public int PeriodSet { get; set; }
public string NewAccountTemplate { get; set; }
public string AccountMaskPrefix { get; set; }
public int AccountMaskDigits { get; set; }
public string Acronym { get; set; }
public string AcronymPath { get; set; }
public DateTime Created { get; set; }
public int CreatedBy { get; set; }
public DateTime LastModified { get; set; }
public int LastModifiedBy { get; set; }
public bool? HasChild { get; set; }
public string CreatedByName { get; set; }
public string LastModifiedByName { get; set; }
}
Here is a sample returned JSON record that causes SfDataManger + SfTreeGrid to fail:
https://localhost:5001/odata/OrgUnits?$count=true&$filter=ParentId%20eq%20null
but the following is OK:
|
Index.razor:-
<SfTreeGrid TValue="Order" @ref="TreeGrid" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="1" HasChildMapping="isParent">
<SfDataManager Url=http://localhost:64956/odata/books Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
<TreeGridColumns>
<TreeGridColumn Field="@nameof(Order.TaskId)" HeaderText="Task ID" Width="80" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn>
. . .
</TreeGridColumns>
</SfTreeGrid>
[Route("api/[controller]")]
public class BooksController : ODataController
{
private BookStoreContext _db;
public BooksController(BookStoreContext context)
{
_db = context;
if (context.Books.Count() == 0)
{
context.Books.AddRange(DataSource.GetBooks());
}
context.SaveChanges();
}
// GET api/values
[HttpGet]
[EnableQuery]
//[System.Web.Http.AllowAnonymous]
public IActionResult Get()
{
return Ok(_db.Books);
}
}
public class Book
{
[Key]
public int TaskId { get; set; }
public byte[] SysTS { get; set; }
public string TaskName { get; set; }
public int Duration { get; set; }
public int Progress { get; set; }
public string Priority { get; set; }
public int? ParentId { get; set; }
public bool? isParent { get; set; }
} |
Hi Farveen,
Thanks for trying, but your example leaves out the SysTS property in the client side class, which I had advised was triggering the problem in the interaction between SfTreeGrid & SfDataManager. While you have added it into the controller on the server side, its not called upon in your client side at all, hence your example works.
In real-use-case, SysTS is needed in the full client-server loop as it is an SQL concurrency field.
Here is complete example that is failing as described.
Please advise.
Regards,
Phil
Hi,
I note that this does not appear to have yet been rectified in the patch planned (today).
Also, for the guys working on this, I seem to experience a similar problem with the call to SfDataManager update, fails with similar client size failing, with no call being made to service endpoint to make the update.
Would be great if when they test this fix, they also include testing all CRUD operations, as I don't think it is only the read operation that is failing.
Regards,
Phil
Hi Farveen,
Its a bit hard to provide code example of the CUD operations failure, when you haven't yet released the fix for the R failure. Only once one reads the data, can they then attempt updating it also.
I had tried a few temporary workarounds to the problem, when led me to think the problem also exists in updating data, not just reading it. Hence my request that when you fix the 1st (read) problem, your QA guys also test CUD operations prior to release. I would have hoped this would be normal regression practice, but just in case not, I asked this.
You have already verified the read problem. All I am asking is in your pre-release QA, please check CUD operations also. That would be much easier than me providing whole workaround code for you to QA.
I look forward to next week's patch then.
Regards,
Phil