This sample demonstrates the synchronization of two different models, necessitated by their being different types: TreeModel for the tree view and GraphLinksModel for the general diagram on the right. Normally in such situations one would have a single model with two diagrams showing the shared model. However in this case there are two separate models but the model data, including the Model.nodeDataArray, are shared. That means the "group" property is used in the normal fashion in the GraphLinksModel but is used as the "parent" reference in the TreeModel.

That introduces some complications when there are changes to the data, since they need to be reflected in other other model even though the data properties have already been changed! This is accomplished by having a Model Changed listener on each model that explicitly updates the other model.

加入 GoJS 交流群
GoJS 交流群 (769862113)