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

Adding data to drawing elements

1 Answer 22 Views
Drawing API
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 1
Kenneth asked on 02 Jun 2015, 09:55 AM

Hi,

 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

 Kenny

1 Answer, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 04 Jun 2015, 08:26 AM

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.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Drawing API
Asked by
Kenneth
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or