简体   繁体   English

获取Kendo UI日历的日期列表

[英]Getting list of dates in view for Kendo UI calendar

How can I get a list of the dates currently visible in Kendo UI Calendar? 如何获取Kendo UI日历中当前可见的日期列表? 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. 例如,2014年4月的视图包括3月30日至5月10日的日期,例如,即使将月份更改为6月,我也需要一种可靠的方法来获取这些日期的列表。

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];
}

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. 注意:由于Java脚本给出了月份索引,因此您必须在月份中添加+1才能获得确切的日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM