I'm attempting to build a template for days in `month` view using view.dayTemplate. The reason I'm doing this is so that I can add a piece of text at the top right of each day showing the number of tasks in that day. Is there a method of accessing the number of events listed for a given day?
Here is my desired template:
<
script
id
=
"monthview-day-template"
type
=
"text/x-kendo-template"
>
<
span
><
span
data-bind="text: <event-count-here>"></
span
> Tasks</
span
>
</
script
5 Answers, 1 is accepted
You can use occurrencesInRange in your template. Execute javascript in the template like:
#var numOfEvents = scheduler.occurrencesInRange(startdate, endDate);#
<p>#:numOfEvents#</p>
I would suggest you to take a look at Create Custom Month Views with Event Count in the Show More Button example. It uses occurrencesInRange, as suggested.
Regards,
Dimitar
Telerik by Progress
If I attempt to execute JS in my template, my function `scheduler.occurencesInRange(a, b) is not defined. It seems that any JS function I attempt to execute inside a kendo template using the template syntax `#= <js code here> #` results in a TypeError. The function is being declared in a JS file on the page instead of an inline <script> tag.
<
script
id
=
"monthview-day-template"
type
=
"text/x-kendo-template"
>
<
span
>#= kendo.toString(date, 'dd') #</
span
>
<
span
>#= scheduler.occurrencesInRange(someStartDate, someEndDate) # Tasksa</
span
>
</
script
>
Apart from the examples in the Custom Views sub-section within the Scheduler' How To documentation section, which the article Dimitar linked is part of, there isn't an article that provides extensive explanation on extending built-in views. The documentation is focused on explaining the built-in features and API of the widgets, rather than on the ways they can be extended by overriding their default behavior. Custom views can be different and would depend on the specific scenario and requirements, thus the articles in the HowTo section simply demonstrate particular scenarios, rather than being tutorials for creating custom views.
Regards,
Ivan Danchev
Telerik by Progress