When using Type=HTML I sometimes get the following error
ThreadPool Callback threw an unhandled exception of type Microsoft.JSInterop.JSExceptionThis only happens when using Type=HTML. If I try Type=Shape everything is okay. Sometimes I can drop 10 items onto the diagram with no problems then other times I'll get an error after dropping just 1 item
I am using the latest version on Syncfusion Blazor
Hi John,
We deeply regret for the inconvenience caused. On the further analysis of the shared sample, we can able to fixed the issue in sample side itself. In the drop event, you have added the node without node ID. By default, in the diagram, if we do not set ID for node means then random ID gets generated for the node. So random ID of number gets added for the node. By default, if we try to get any element which ID is number from DOM using query selector means we face exception. To resolve this, add the ID for the dropped node as below code snippet. So that newly added node gets added properly in the node without any exception.
|
public void OnDrop(IBlazorDropEventArgs args) { args.Cancel = true; var NewNode = args.Element.Node; Diagram.Nodes.Add(new DiagramNode() { // Set the ID for the node Id = "node" + Diagram.Nodes.Count, OffsetX = NewNode.OffsetX, OffsetY = NewNode.OffsetY, Width = NewNode.Width, Height = NewNode.Height, Shape = new DiagramShape() { Type = Shapes.HTML, }
}); } |
We have attached a video demonstration of how newly added node gets added properly in the node without any exception.
Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NODETE~1-443852115
We have modified the sample and attached for your reference. Please find the sample in below link
Regards
Gowtham
|
public void OnDrop(IBlazorDropEventArgs args)
{
args.Cancel = true;
var NewNode = args.Element.Node;
Diagram.Nodes.Add(new DiagramNode()
{
// Set the ID for the node
Id = "node" + Diagram.Nodes.Count,
OffsetX = NewNode.OffsetX,
OffsetY = NewNode.OffsetY,
Width = NewNode.Width,
Height = NewNode.Height,
Shape = new DiagramShape()
{
Type = Shapes.HTML,
}
});
} |