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

Getting error Uncaught TypeError: Cannot read property 'occurrenceByUid' of undefined when having Custom event template

5 Answers 556 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Coolasia
Top achievements
Rank 1
Coolasia asked on 21 Apr 2015, 09:33 AM

Hi Telerik Team,

I have defined custom event template for my scheduler. When I move event in the scheduler I am getting errror as "Uncaught TypeError: Cannot read property 'occurrenceByUid' of undefined".

When I debugged the Javascript and found that the error is coming in the below code

(function(data
/**/) {
var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='\n    ';var uid = target.attr("data-uid");;$kendoOutput+='\n    ';var scheduler = target.closest("[data-role=scheduler]").data("kendoScheduler");;$kendoOutput+='\n    ';var model = scheduler.occurrenceByUid(uid);;$kendoOutput+='\n   \n    ';if(model) {;$kendoOutput+='\n        <strong>Job Start:</strong> '+(kendo.format('{0:ddd M/dd, hh:mm tt}',model.start))+'<br />\n        <strong>Job End:</strong> '+(kendo.format('{0:ddd M/dd, hh:mm tt}',model.end))+'<br />\n        <strong>Job Details:</strong> '+(model.title)+'<br />\n    <strong>Job Address:</strong> '+(model.Address)+'\n    ';} else {;$kendoOutput+='\n        <strong>No event data is available</strong>\n    ';};$kendoOutput+='\n';}return $kendoOutput;
})

 

where the "var scheduler = target.closest("[data-role=scheduler]").data("kendoScheduler")" is undefined and the error is coming. Please help how to fix it.

5 Answers, 1 is accepted

Sort by
0
Coolasia
Top achievements
Rank 1
answered on 22 Apr 2015, 08:42 AM

Hi Team,

I want to add one more point for above error. I am using telerik tool tip for the scheduler event.

The above error is the from the tooltip script.

 So please let me know where I am wrong.

0
Vladimir Iliev
Telerik team
answered on 23 Apr 2015, 08:20 AM
Hello,

From the provided information it seems that the scheduler object is not found when dragging the event outside the scheduler - you can improve the tooltip template as follows:

#var uid = target.parent().attr("data-uid");#
#var scheduler = target.closest("[data-role=scheduler]").data("kendoScheduler");#
#var model =  scheduler ? scheduler.occurrenceByUid(uid) : null;#

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Coolasia
Top achievements
Rank 1
answered on 23 Apr 2015, 08:44 AM

Hi Vladimir Iliev,

 Thank you for the solution.

This fixed the error but I found something new, the tool tip is displaying blank when there is no model. I do not want to show like that, is it possible to hide it when there is no model. 

 Please see attached screen for easy understanding

0
Coolasia
Top achievements
Rank 1
answered on 27 Apr 2015, 07:00 AM

Hi Telerik Team,

 Can some one please reply to my previous post.

Thanks,

Coolasia

0
Vladimir Iliev
Telerik team
answered on 27 Apr 2015, 07:51 AM
Hello,

In the described scenario the best way to hide the tooltip is to not showing it when dragging events. This can be achieved by improving the current filter as follows:

filter: ".k-event:not(.k-event-drag-hint) > div"

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
Coolasia
Top achievements
Rank 1
Answers by
Coolasia
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or