I need to allow to edit a diagram, but I must keep a logic relation where children items can only be attached to elements on the first parent level. Right now there is no event nor an option to do this that I know of.
6 Answers, 1 is accepted
Currently there are no such event but I would suggest to submit your request in Kendo's UserVoice so other members of the community can evaluate, comment on and vote for it.
Regards,
Hristo Germanov
Telerik
Here is the User Voice post:
http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback/suggestions/7694934-diagram-event-for-connection-created
If I can't find a way around not having connection events, this is probably a deal breaker for us.
Here's what I'm going to try:
1. Detect the connection add event
2. Get the shape from the first mouse enter event (this is the shape the connection initiated from)
3. Get the next shape from the mouse enter event and make sure it's different from the originating shape.
4. Detect the mouse leave event and then query the connections and check the newly added connection to see if it has a shape in the to property.
If you are using a diagram bound via a dataSource and a connectionsDataSource then you could use the connectionsDataSource change event. It will be triggered for the from and to fields when a connection is connected to a shape. For a hierarchical dataSource currently I cannot currently suggest any better solution. I am sorry for the inconvenience caused.
Regards,
Daniel
Telerik
Thanks Daniel, it looks like this may work. I do have a question on how to subscribe to the change event as I'm not setting up the data source like the examples. I'm using the setConnectionsDataSource method.
ex. $scope.integrationDiagram.setConnectionsDataSource(vm.connections); //vm.connections is an array of from: to: connection objects.
Thank you for your help
You could either set a dataSource instance and set the handler in the options:
$scope.integrationDiagram.setConnectionsDataSource(
new
kendo.data.DataSource({
data: vm.connections,
change: changeHandler
}));
$scope.integrationDiagram.setConnectionsDataSource(vm.connections);
$scope.integrationDiagram.connectionsDataSource.bind(
"change"
, changeHandler);
Regards,
Daniel
Telerik