Adding data to drawing elements

2 posts, 1 answers
  1. Kenneth
    Kenneth avatar
    7 posts
    Member since:
    Oct 2013

    Posted 02 Jun 2015 Link to this post


     I was wondering if it is possible somehow to add data to the drawing elements such as an image or a path?  I realise this probably won't be possible with the canvass surface type.

     I want to be able to detect a drag start or end so I can drag items onto the surface or to drag items off the surface.  I will need to know that the reference number the item is in my system so that's why I want to store data on the elements.

    If this is not possible, that would be useful information to me as it would allow me to start considering another framework such as Raphael for what I am trying to achieve.

    Thanks in advance


  2. Answer
    T. Tsonev
    T. Tsonev avatar
    2794 posts

    Posted 04 Jun 2015 Link to this post

    Hello Kenneth,

    The Shape elements are plain objects that can also carry expando properties, e.g.

    var rect = new kendo.drawing.Rect(...);
    rect.myData = { };

    Whenever you get a reference to this shape, e.g. from the Surface events, you'll also have access to your properties.

    The Surface also has an eventTarget method that allows you to obtain a reference to a shape from a DOM element.

    The Canvas surface doesn't do this, as you've guessed. We have plans to add hit testing that will allow us to implement this for it as well.

    I hope this helps.

    T. Tsonev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top