Dynamically Updating Local Data at Runtime

Good Day,

A scenario I don't seem to be able to get right, is to update a diagram node at runtime, using "local data" bindings.

1. I have a DataSource defined as ObservableCollection<DiagProdLineBase>
2. The DiagProdLineBase class has a Text property defined, which is mapped in the DiagramDataMapSetting tag as an annotation (see below)
3. The diagram renders correctly the first time it's drawn

4. After initial render, I change one instance of the DataSource collection, updating the text property of one of the DiagProdLineBase instances.
5. I would have then assumed, that the Diagram picks up on the change and updates the node annotation

I have tried Diagram.DataBind, StatehasChanged, with no update
I have tried to modify the Diagram Nodes collection directly on the Diagram object (updating Annotation and even the JSON Data property). No success.
The only thing that works, is calling Diagram.Clear() and then Diagram.Refresh(), but I would assume there is a more elegant way.

What am I missing? How do I signal to the Diagram control, that it needs to re-bind to the data source?

Thank you,
Peter

<SfDiagram @ref="@Diagram" id="diagram" Width="100%" Tool="@DiagramTools.ZoomPan" Height="580px" NodeDefaults="@NodeDefaults" ConnectorDefaults="@ConnectorDefaults" Layout="@LayoutValue">
    <DiagramDataSource Id="Id" ParentId="ParentItems" DataSource="@DataSource">
        <DiagramDataMapSettings>
            <DiagramDataMapSetting Property="Annotations[0].Content" Field="Text"></DiagramDataMapSetting>
            <DiagramDataMapSetting Property="Style.fill" Field="FillColor"></DiagramDataMapSetting>
            <DiagramDataMapSetting Property="Style.strokeColor" Field="Border"></DiagramDataMapSetting>
        </DiagramDataMapSettings>
    </DiagramDataSource>
    <DiagramPageSettings>
        <DiagramFitOptions CanFit="@CanFit" Mode="@Mode"></DiagramFitOptions>
    </DiagramPageSettings>
    <DiagramSnapSettings Constraints="SnapConstraints.None"></DiagramSnapSettings>
</SfDiagram>

1 Reply

AR Aravind Ravi Syncfusion Team May 21, 2020 03:29 PM UTC

Hi Peter, 

Currently we don’t have Binding support for data source property in our diagram control. We have logged “Binding support for data source property” as a feature. We does not have any immediate plans to start this feature. We will implement this feature in any one of our upcoming releases.       

You can track the feature status from the below link 

Regards  
Aravind Ravi  


Loader.
Up arrow icon