Today, I upgraded from 18.2.0.46 to 18.2.0.48, and the TreeGrid started failing with the following error:
System.InvalidOperationException: The converter specified on 'Syncfusion.Blazor.TreeGrid.TreeGridColumn.EditTemplate' does not derive from JsonConverter or have a public parameterless constructor.
After some investigation, I ended up removing the binding from Columns="" and replacing it with a foreach like below:
<TreeGridColumns>
@foreach (var treeGridColumn in @TreeColumns)
{
<TreeGridColumn Field="@treeGridColumn.Field" HeaderText="@treeGridColumn.HeaderText" Width="@treeGridColumn.Width"></TreeGridColumn>
}
</TreeGridColumns>
which ended up fixing my problem and now the TreeGrid shows the columns and I don't get the above error.
However, after the data is populated I see it flashing in the UI and then immediately disapears.
Again, I am still using a Custom Adaptor like below:
<SfDataManager CrossDomain="true" AdaptorInstance="@typeof(CustomAdaptor)"
Adaptor="Syncfusion.Blazor.Adaptors.CustomAdaptor" Offline="true">
</SfDataManager>
so my problem now is that the data when loaded flashes for a quick millisecond on the UI, and then disappears leaving the TreeGrid with the message "No Records to Display".
Can you please let me know what needs to change?
This is my Adaptor Read:
public override object Read(DataManagerRequest dm, string key = null)
{
var results = new List<ExpandoObject>(CustomService.TreeGridRows);
IEnumerable<ExpandoObject> dataSource = results;
if (dm.Search != null && dm.Search.Count > 0)
{
// Searching
dataSource = DataOperations.PerformSearching(dataSource, dm.Search);
}
if (dm.Sorted != null && dm.Sorted.Count > 0)
{
// Sorting
dataSource = DataOperations.PerformSorting(dataSource, dm.Sorted);
}
//if (dm.Where != null && dm.Where.Count > 0)
//{
// // Filtering
// dataSource = DataOperations.PerformFiltering(dataSource, dm.Where, dm.Where[0].Operator);
//}
var count = dataSource.Cast<ExpandoObject>().Count();
if (dm.Skip != 0)
{
//Paging
dataSource = DataOperations.PerformSkip(dataSource, dm.Skip);
}
if (dm.Take != 0)
{
dataSource = DataOperations.PerformTake(dataSource, dm.Take);
}
return dm.RequiresCounts ? new DataResult() { Result = dataSource, Count = count } : (object)dataSource;
}
and here is the TreeGrid razor code:
<SfTreeGrid @ref="TreeGrid" TValue="ExpandoObject" IdMapping="Id"
ParentIdMapping="ParentId"
TreeColumnIndex="0" AllowPaging="true" EditSettings="@EditSettings">
<SfDataManager CrossDomain="true" AdaptorInstance="@typeof(CustomAdaptor)"
Adaptor="Syncfusion.Blazor.Adaptors.CustomAdaptor" Offline="true">
</SfDataManager>
<TreeGridPageSettings PageCount="2" PageSize="20" PageSizeMode="PageSizeMode.All"></TreeGridPageSettings>
<TreeGridColumns>
@foreach (var treeGridColumn in @TreeColumns)
{
<TreeGridColumn Field="@treeGridColumn.Field" HeaderText="@treeGridColumn.HeaderText" Width="@treeGridColumn.Width"></TreeGridColumn>
}
</TreeGridColumns>
</SfTreeGrid>