how can we bind data to kendo calendar from database?, if this possible please give me any solution....
Here's my code
var today = new Date();
var events = new kendo.data.DataSource({
transport: {
read: {
url: '@Url.Action("GetCalendarDate", "Calendar")',
dataType: 'json'
}
},
});
$("#calendar").kendoCalendar({
change: onChange,
value: today,
dates: events,
month: {
content: '# if ($.inArray(+data.date, data.dates) != -1) { #' +
'<div class="' +
'# if (data.value < 10) { #' +
"exhibition" +
'# } else if ( data.value< 20 ) { #' +
"party" +
'# } else { #' +
"cocktail" +
'# } #' +
'">#= data.value #</div>' +
'# } else { #' +
'#= data.value #' +
'# } #'
}
});
But it doesn't work. please anyone can tel me the write way for that, Please help me.
Thanks.
8 Answers, 1 is accepted
The Kendo UI Calendar does not support data binding. As it is a static widget that offers date selection functionality there is not really a point in data bindings. If you want to show events in a Scheduler like widget, I would suggest you to take a look at the following demo:
http://demos.telerik.com/kendo-ui/scheduler/index
Regards,
Kiril Nikolov
Telerik
but i done that data binding form database to kendo calendar
thank you
The Calendar does not support dataBinding, and there is no documentation or a demo article that shows such functionality. I would still suggest you to consider the Kendo UI Scheduler if you want to show events in a Calendar like widget.
Regards,
Kiril Nikolov
Telerik
Hi Livashini,
Can you share data binding from database to kendo calendar, Please
Hello Anushri,
As I said in my previous response - the calendar does not support data binding.
Regards,
Kiril Nikolov
Telerik
I Used ajax for return data from database, after return the data i wrote following function to bind dates to calender
function GetCal(dataCal) {
var events = new Array();
$.holdReady( true );
for (i = 0; i < dataCal.length; i++) {
events.push(+new Date(dataCal[i].YY, dataCal[i].MM, dataCal[i].DD));
}
$("#calendar").kendoCalendar({
change: onChange,
value: today,
dates: events,
month: {
// template for dates in month view
content: '# if ($.inArray(+data.date, data.dates) != -1) { #' +
'<div class="' +
'# if (data.value < 10) { #' +
"exhibition" +
'# } else if ( data.value < 20 ) { #' +
"party" +
'# } else { #' +
"cocktail" +
'# } #' +
'">#= data.value #</div>' +
'# } else { #' +
'#= data.value #' +
'# } #'
},
footer: false
});
}