Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
I have a function named "updateData", which fills my Connector- and NodeCollections. I have 10 Connectionobjects and 11 Nodes.
I am getting a correct diagram, when i am calling the function from OnInitialized().
When i call the function through a button click, i am getting just some (11 + 10) not connected boxed.
protected override void OnInitialized()
{
//updateData();
}
private void updateData()
{
var tree = chartservice.GetDashboard();
var rowList = tree.Rows;
foreach (DataRow node in rowList)
{
var diagramNode = new DiagramNode { Id = node["Id"].ToString(), Annotations = new ObservableCollection() { new DiagramNodeAnnotation() { Content = node["Titel"].ToString() } } };
NodeCollection.Add(diagramNode);
int nodeId = int.Parse(node["Id"].ToString());
if (nodeId > 0)
{
var connector = new DiagramConnector() { Id = "connector" + node["Id"].ToString(), SourceID = node["ParentId"].ToString(), TargetID = node["Id"].ToString() };
ConnectorCollection.Add(connector);
}
}
}
System.InvalidCastException: Unable to cast object of type 'Syncfusion.EJ2.Blazor.Diagrams.DiagramNode' to type 'Syncfusion.EJ2.Blazor.BaseComponent'.
at Syncfusion.EJ2.Blazor.BaseComponent.UpdateCollectionValue(Object propertyValue, Type propertyType, Nullable`1 ejsIndex, Object model, Boolean isAutoInitialized)
at Syncfusion.EJ2.Blazor.BaseComponent.UpdateComponentModel(Dictionary`2 properties, BaseComponent parentObject, Boolean isAutoInitialized)
at Syncfusion.EJ2.Blazor.BaseComponent.UpdateModel(Dictionary`2 properties)
Error: System.InvalidCastException: Unable to cast object of type 'Syncfusion.EJ2.Blazor.Diagrams.DiagramNode' to type 'Syncfusion.EJ2.Blazor.BaseComponent'.
at Syncfusion.EJ2.Blazor.BaseComponent.UpdateCollectionValue(Object propertyValue, Type propertyType, Nullable`1 ejsIndex, Object model, Boolean isAutoInitialized)
at Syncfusion.EJ2.Blazor.BaseComponent.UpdateComponentModel(Dictionary`2 properties, BaseComponent parentObject, Boolean isAutoInitialized)
at Syncfusion.EJ2.Blazor.BaseComponent.UpdateModel(Dictionary`2 properties)
at Object.endInvokeDotNetFromJS (https://localhost:44380/_framework/blazor.server.js:8:31660)
at e.(https://localhost:44380/_framework/blazor.server.js:8:103446)
at https://localhost:44380/_framework/blazor.server.js:1:19202
at Array.forEach ()
at e.invokeClientMethod (https://localhost:44380/_framework/blazor.server.js:1:19173)
at e.processIncomingData (https://localhost:44380/_framework/blazor.server.js:1:17165)
at e.connection.onreceive (https://localhost:44380/_framework/blazor.server.js:1:10276)
at WebSocket.i.onmessage (https://localhost:44380/_framework/blazor.server.js:1:38091)