Handle click on connection visual

5 posts, 0 answers
  1. Itai
    Itai avatar
    33 posts
    Member since:
    Feb 2016

    Posted 22 Sep Link to this post

    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.

  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 26 Sep Link to this post

    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.
     
  3. Kendo UI is VS 2017 Ready
  4. Itai
    Itai avatar
    33 posts
    Member since:
    Feb 2016

    Posted 28 Sep in reply to Slav Link to this post

    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?

  5. Itai
    Itai avatar
    33 posts
    Member since:
    Feb 2016

    Posted 28 Sep Link to this post

    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? 

  6. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 29 Sep Link to this post

    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.
     
Back to Top
Kendo UI is VS 2017 Ready