Hi,
I'm trying to dynamically generate RadzenSelectBars via Renderfragments. This fails, unfortunately, with an error:
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Error: No element is currently associated with component 14
System.InvalidOperationException: Error: No element is currently associated with component 14
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit 'Gp5GP5pHjs8iB6J11Sn_6QzLdZ66ebdnimbuzKqq3aw'.
System.AggregateException: One or more errors occurred. (Error: No element is currently associated with component 14)
---> System.InvalidOperationException: Error: No element is currently associated with component 14
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)
--- End of inner exception stack trace ---
Here's the code for the builder:
OpFragment = builder =>
{
base.BuildRenderTree(builder);
builder.OpenComponent<RadzenSelectBar<int>>(0);
builder.AddAttribute(1, "TValue", "int");
builder.OpenElement(2, "Items");
builder.OpenComponent<RadzenSelectBarItem<int>>(3);
builder.AddAttribute(4, "Text", "blah");
builder.AddAttribute(5, "Value", 1);
builder.CloseComponent();
builder.CloseElement();
builder.CloseComponent();
};
Here's a similar code that creates a Dropdown instead, which works fine:
OpFragment = builder =>
{
base.BuildRenderTree(builder);
//builder.OpenComponent(0, typeof(RadzenSelectBar<int>));
builder.OpenComponent<RadzenDropDown<string>>(0);
builder.AddAttribute(1, "TValue", "string");
builder.AddAttribute(2, "Data", new string[]{"x","y" });
builder.CloseComponent();
};
This is server-side Blazor, btw.