Full error within chome dev tools using SfDataManager:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Blazor.TreeGrid.SfTreeGrid`1[[ Project .Shared.Models.Group, Project.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ConvertToFlatData(DataReadyArgs`1 dm)
at Syncfusion.Blazor.TreeGrid.SfTreeGrid`1[[ Project .Shared.Models.Group, Project .Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetFlatData(IEnumerable dataSource, DataReadyArgs`1 dm, Boolean isRemoteChild, Boolean isGanttRecord)
at Syncfusion.Blazor.TreeGrid.Internal.GridRenderer`1[[ Project .Shared.Models.Group, Project .Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GridDataBound(Object data)
at Syncfusion.Blazor.Grids.Internal.EventAggregator.<>c__DisplayClass2_0.<Notify>b__0(Action`1 handler)
at System.Collections.Generic.List`1[[System.Action`1[[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ForEach(Action`1 action)
at Syncfusion.Blazor.Grids.Internal.EventAggregator.Notify(String name, Object args)
at Syncfusion.Blazor.Grids.SfGrid`1.<VirtualDataProcess>d__412[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Syncfusion.Blazor.Grids.SfGrid`1.<DataProcessChild>d__410[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Syncfusion.Blazor.Grids.SfGrid`1.<DataProcess>d__409[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Syncfusion.Blazor.Grids.SfGrid`1.<DataProcess>d__409[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at Syncfusion.Blazor.Grids.Internal.Preloader`1.<OnParametersSetAsync>d__21[[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()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
TreeGrid component with SfDataManager that errors
<SfTreeGrid @ref="GroupTreeGrid" TValue="Group" Query="@GroupsQuery" Toolbar="@(new List<string>() { "Search", "Add", "Delete" })" AllowRowDragAndDrop="true" Height="auto" IdMapping="GroupID" ParentIdMapping="ParentGroupID" TreeColumnIndex="1">
<SfDataManager @ref="GroupsAdaptor" Url="api/groups" CrossDomain="true" Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor"></SfDataManager>
<TreeGridEvents QueryCellInfo="QueryCellInfoHandler" RowSelected="RowSelectHandler" RowDeselected="RowDeSelectHandler" TValue="Group"></TreeGridEvents>
<TreeGridPageSettings PageSize="2"></TreeGridPageSettings>
<TreeGridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></TreeGridSelectionSettings>
<TreeGridEditSettings AllowAdding="true" AllowDeleting="true" Mode="EditMode.Dialog">
<Template>
@{
var Group = (context as Group);
<div>
<div class="form-row">
<div class="form-group col-md-12">
<SfTextBox ID="GroupID" @bind-Value="@Group.GroupID" FloatLabelType="FloatLabelType.Always" Placeholder="Group ID"></SfTextBox>
</div>
<div class="form-group col-md-12">
<SfTextBox ID="Name" @bind-Value="@Group.Name" FloatLabelType="FloatLabelType.Always" Placeholder="Name"></SfTextBox>
</div>
<div class="form-group col-md-12">
<SfTextBox ID="ImageURL" @bind-Value="@Group.ImageURL" FloatLabelType="FloatLabelType.Always" Placeholder="Image"></SfTextBox>
</div>
<div class="form-group col-md-12">
<SfTextBox ID="Description" Multiline="true" @bind-Value="@Group.Description" FloatLabelType="FloatLabelType.Always" Placeholder="Description"></SfTextBox>
</div>
</div>
</div>
}
</Template>
</TreeGridEditSettings>
<TreeGridColumns>
<TreeGridColumn Field="GroupID" IsPrimaryKey="true" HeaderText="Group ID" Visible="false"></TreeGridColumn>
<TreeGridColumn Field="Name" HeaderText="Group Name"></TreeGridColumn>
</TreeGridColumns>
</SfTreeGrid>
TreeGrid component with Datasource that works
<SfTreeGrid DataSource="GroupsList" @ref="GroupTreeGrid" TValue="Group" Query="@GroupsQuery" Toolbar="@(new List<string>() { "Search", "Add", "Delete" })" AllowRowDragAndDrop="true" Height="auto" IdMapping="GroupID" ParentIdMapping="ParentGroupID" TreeColumnIndex="1">
<TreeGridEvents QueryCellInfo="QueryCellInfoHandler" RowSelected="RowSelectHandler" RowDeselected="RowDeSelectHandler" TValue="Group"></TreeGridEvents>
<TreeGridPageSettings PageSize="2"></TreeGridPageSettings>
<TreeGridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></TreeGridSelectionSettings>
<TreeGridEditSettings AllowAdding="true" AllowDeleting="true" Mode="EditMode.Dialog">
<Template>
@{
var Group = (context as Group);
<div>
<div class="form-row">
<div class="form-group col-md-12">
<SfTextBox ID="GroupID" @bind-Value="@Group.GroupID" FloatLabelType="FloatLabelType.Always" Placeholder="Group ID"></SfTextBox>
</div>
<div class="form-group col-md-12">
<SfTextBox ID="Name" @bind-Value="@Group.Name" FloatLabelType="FloatLabelType.Always" Placeholder="Name"></SfTextBox>
</div>
<div class="form-group col-md-12">
<SfTextBox ID="CaddieImageG" @bind-Value="@Group.ImageURL" FloatLabelType="FloatLabelType.Always" Placeholder="Image"></SfTextBox>
</div>
<div class="form-group col-md-12">
<SfTextBox ID="Description" Multiline="true" @bind-Value="@Group.Description" FloatLabelType="FloatLabelType.Always" Placeholder="Description"></SfTextBox>
</div>
</div>
</div>
}
</Template>
</TreeGridEditSettings>
<TreeGridColumns>
<TreeGridColumn Field="GroupID" IsPrimaryKey="true" HeaderText="Group ID" Visible="false"></TreeGridColumn>
<TreeGridColumn Field="Name" HeaderText="Group Name"></TreeGridColumn>
</TreeGridColumns>
</SfTreeGrid>
Code definitions
public List<Group> GroupsList = new List<Group>();
SfTreeGrid<Group>? GroupTreeGrid = null;
SfDataManager? GroupsAdaptor = null;
Query? GroupsQuery { get; set; } = null;
Group? SelectedData = new Group();
public partial class Group
{
[Key]
public int ID { get; set; }
public string? GroupID { get; set; }
public string? ParentGroupID { get; set; }
public string? Name { get; set; }
public string? ShopID { get; set; }
public bool Archived { get; set; }
public bool ShowInApp { get; set; }
public string? ImageURL { get; set; }
public string? Description { get; set; }
}
Controller API Get
public async Task<ActionResult> Get(string shopid, string? search = null, string orderby = "Name", bool all = false, bool count = false)
{
try
{
if (Request.Query.Keys.Contains("$orderby"))
{
orderby = Request.Query["$orderby"];
}
IQueryable<Group> groups = from u in context.Groups where u.ShopID == shopid select u;
if (!all)
{
groups = from p in groups where p.Archived == false select p;
}
if (!String.IsNullOrEmpty(search))
{
groups = groups.Where(c => c.Name.Contains(search) || c.Description.Contains(search));
}
if (!string.IsNullOrWhiteSpace(orderby))
{
var sort = orderby.Split(",".ToCharArray());
foreach (var s in sort)
{
if (s.EndsWith(" desc"))
{
string[] parts = s.Split(" ");
groups = groups.OrderByDescending(parts.First());
}
else
{
groups = groups.OrderBy(s);
}
}
}
if (count)
{
var js = new { Items = await groups.ToListAsync(), Count = await groups.CountAsync() };
return Ok(js);
}
else
{
return Ok(new { Items = await groups.ToListAsync() });
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Get Groups");
return NotFound();
}
}
Local data on initialisation for datasource that works
protected override void OnInitialized()
{
GroupsList.Add(new Group() { ID = 1, GroupID = "1", Name = "Club", ShopID = "DEMO", Archived = false, ParentGroupID = null, ShowInApp = true });
GroupsList.Add(new Group() { ID = 2, GroupID = "2", Name = "Accessories", ShopID = "DEMO", Archived = false, ParentGroupID = "1", ShowInApp = true });
GroupsList.Add(new Group() { ID = 3, GroupID = "3", Name = "Accessories - More", ShopID = "DEMO", Archived = false, ParentGroupID = "1", ShowInApp = true });
GroupsQuery = new Query().AddParams("shopid", shop.id).AddParams("search", null).AddParams("orderby", "Name").AddParams("all", false).AddParams("count", false);
}
What is this error referring to?