I'm trying to create a connection between nodes using a datamanager
But when I specify connectionDataSource, the nodes disappear and the screen is empty, there are no errors in the console
我正尝试使用数据管理器在节点之间创建连接,但当我指定ConnectionDataSource时,节点消失,屏幕为空,控制台中没有错误
@Component({
selector: 'app-relationship-playground-component',
template: `<ejs-diagram id="diagram" width="100%" height="580px" [layout]='layout' [dataSourceSettings]='dataSourceSettings' [getNodeDefaults]='nodeDefaults' [getConnectorDefaults]='connectorDefaults'>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class RelationshipPlaygroundComponentComponent implements OnInit{
@ViewChild("diagram") public layout?: LayoutModel;
public dataSourceSettings?: DataSourceModel;
public connections : Object[] = [
{
id: "a96b708d-9878-409b-9424-79afd536fbcb",
source: "e0ad8a67-65a4-488e-a13e-af4a51095da4",
target: "991d0d06-f084-43df-871d-2c501a41108e",
}
]
public elements : Object[] = [
{
caption: "Accom (sample)",
id: "e0ad8a67-65a4-488e-a13e-af4a51095da4",
recordId: "405947d0-2ffb-4ded-8675-0475f19f5a81",
},
{
caption: "Our company",
id: "991d0d06-f084-43df-871d-2c501a41108e",
recordId: "e308b781-3c5b-4ecb-89ef-5c1ed4da488e",
}
]
public nodeDefaults(node: NodeModel): NodeModel {
return node;
}
public connectorDefaults(connector: ConnectorModel): ConnectorModel {
connector.type = "Orthogonal";
connector.cornerRadius = 7;
return connector;
}
ngOnInit(): void {
this.layout = {
type: "HierarchicalTree", verticalSpacing: 40
};
this.dataSourceSettings = {
id: "id",
dataManager: new DataManager(this.elements as JSON[]),
connectionDataSource: {
id: 'id',
sourceID: 'source',
targetID: 'target',
dataManager: new DataManager(this.connections as JSON[])
}
};
}
}
I took examples from the documentation and the sample repository
https://github.com/syncfusion/ej2-samples/blob/master/src/diagram/crud.ts
我采用了文档和样本库https://github.com/syncfusion/ej2-samples/blob/master/src/diagram/crud.ts中的示例
https://ej2.syncfusion.com/angular/documentation/diagram/data-binding#how-to-perform-editing-at-runtime
Https://ej2.syncfusion.com/angular/documentation/diagram/data-binding#how-to-perform-editing-at-runtime
更多回答
优秀答案推荐
A Hierarchical Tree layout using DataManager has been rendered. In DataManager, you need to assign a JSON object with Id and parentId, and this DataManager is then assigned to the dataSource property in dataSourceSettings. The layout is rendered based on the ID and parentId defined in the layout. When rendering the layout, there is no need to set a connectionDataSource.
已呈现使用DataManager的分层树布局。在DataManager中,您需要分配一个具有ID和parentID的JSON对象,然后将此DataManager分配给dataSourceSetting中的DataSource属性。布局基于布局中定义的ID和parentID呈现。在呈现布局时,不需要设置ConnectionDataSource。
Documentation
https://ej2.syncfusion.com/angular/documentation/diagram/automatic-layout
文档https://ej2.syncfusion.com/angular/documentation/diagram/automatic-layout
Sample
https://stackblitz.com/edit/angular-dzj1jr-87pxp8?file=src%2Fapp.component.html
示例https://stackblitz.com/edit/angular-dzj1jr-87pxp8?file=src%2Fapp.component.html
更多回答
This doesn't answer my question. My connections and nodes come from the backend in separate parts. And I would like to know if it is possible to draw a conclusion using dataSourceSettings, simply specifying the model for nodes and connections, and specifying what connections they should be based on, as can be seen from my example
这并没有回答我的问题。我的连接和节点来自后端的不同部分。我想知道是否可以使用dataSourceSetting得出结论,只需指定节点和连接的模型,并指定它们应该基于什么连接,如我的示例所示
Also in the presented question there is a link to a repository with a possible implementation, but it is made for obtaining data from the network, not local
在所提出的问题中,还存在到具有可能实现的存储库的链接,但其目的是从网络获取数据,而不是本地数据
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
您的回答可以通过补充支持信息进行改进。请编辑以添加更多细节,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以在帮助中心找到更多关于如何写好答案的信息。
我是一名优秀的程序员,十分优秀!