Question

How can I get a list of the dates currently visible in Kendo UI Calendar? For example, the view for April 2014 includes dates from 30th March to 10th May, and I need a reliable way to get a list of those dates, even when changing month to June, for example.

UPDATE: For those who want the resulting solution inspired by the answer below, this is it (simplified for easier readability):

$("#calendar").kendoCalendar({
    navigate: function() {
        window.visibleDates = getVisibleDates(this);
    }
});

var getVisibleDates = function(obj) {
    var firstDay = $("tbody > tr:first > td:first > a", obj.element).data("value");
    var lastDay = $("tbody > tr:last > td:last > a", obj.element).data("value");

    var start = new Date(parseFloat(firstDay.split("/")[0]), parseFloat(firstDay.split("/")[1]), parseFloat(firstDay.split("/")[2]));
    var end = new Date(parseFloat(lastDay.split("/")[0]), parseFloat(lastDay.split("/")[1]), parseFloat(lastDay.split("/")[2]));

    return [start, end];
}
Was it helpful?

Solution

Please try with the below code snippet.

var cal = $("#calendar").data("kendoCalendar");
var first = $("tbody > tr:first > td:first > a", cal._table).data("value");
var last = $("tbody > tr:last > td:last > a", cal._table).data("value");

Note : As java-script giving the month index, so you have to add +1 in month to get the exact date.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top