This is a migrated thread and some comments may be shown as answers.

Handle click on connection visual

4 Answers 56 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Itai
Top achievements
Rank 1
Itai asked on 22 Sep 2016, 12:38 PM

Hello, 

I want to be able to catch and handle a mouse click on the visual (label) of a connection, not just the line itself. 

 

I'm doing something like

 

connection.redraw({content: {visual: function(){return new TextBlock(...);}}})

It seems the `TextBlock` as well as other visual diagram elements don't have `onclick` events, and sadly the diagram click only fires when clicking on shapes or connections, and I couldn't get it to fire when clicking on the visual of a connection.  

 

Please advise how to identify and handle a click on the visual of a connection.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 26 Sep 2016, 11:38 AM
Hi Itai,

The visual does not include an option for attaching a handler for click event of the connection label. Nevertheless you can attach a click handler for the element of the diagram and check whether the event target is the element you want to track, in your case the label of the connection.

This is shown in the following example with a simple check for the clicked element and its content: http://dojo.telerik.com/EReXU

Regards,
Slav
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Itai
Top achievements
Rank 1
answered on 28 Sep 2016, 05:54 AM

Thank you for the response.

What is the recommended way of using this in conjunction with the diagram's `click` configuration? 

Should I have two separate event handlers or is it better (or even possible?) to call one from the other?

0
Itai
Top achievements
Rank 1
answered on 28 Sep 2016, 06:08 AM

Also - is there a way to retrieve the connection item for this visual? (Without having the text equal the id, or anything that the user will be forced to see)

Alternatively, is there a way to store data with the <text> element when creating a `TextBlock` or a similar diagram visual object? 

0
Slav
Telerik team
answered on 29 Sep 2016, 04:12 PM
Hi Itai,

The additional handler should not get in the way of the one that tracks the clicks on shapes and connections so you can have them both in the implementation.

The text element that renders the visual does not have a reference to the actual visual, so getting it or the connection element will not be easy. You could either get the text in the content of the element or its coordinates and search for a connection that has a visual with the same content or coordinates.

Regards,
Slav
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Diagram
Asked by
Itai
Top achievements
Rank 1
Answers by
Slav
Telerik team
Itai
Top achievements
Rank 1
Share this question
or