简体   繁体   中英

how to get current month and year of Kendo calendar

Is there any way get current month of calendar? when I navigate through navigation options in calendar, I wanted to display previous, present and next month and year.

If you define your calendar as follows you will get a trace in the console every time you change month displaying the previous, current and next month.

var cal = $("#cal").kendoCalendar({
    navigate: function (e) {
        var cur = new Date(this._current);
        var prev = new Date(cur);
        prev.setMonth(cur.getMonth() - 1);
        var next = new Date(cur);
        next.setMonth(cur.getMonth() + 1);
        console.log("-----------");
        console.log("prev", prev);
        console.log("cur ", cur);
        console.log("next", next);
    }
}).data("kendoCalendar");

What I do is get from _current the pre-selected date on current displayed month and then increment or decrement by one the month number.

Running example here : http://jsfiddle.net/OnaBai/W9VFB/1/

You can define depth to year, so the calender will show months and years. I hope this will help you.

 $("#calendar").kendoCalendar({
    depth: "year"
     });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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