Skip a month in the Calendar

19 Dec 20221 minute to read

The following example demonstrates how to skip a month in the Calendar while clicking the previous and next icons. In the example below, the navigated event is used to skip a month with navigateTo method.

<ejs-calendar id="calendar" navigated="onNavigate"></ejs-calendar>

<script>
    function onNavigate(args) {
        var date;

        if ((args.event.currentTarget).classList.contains("e-next")) {
            date = new Date(args.date.setMonth(args.date.getMonth() + 1));
        }
        if ((args.event.currentTarget).classList.contains('e-prev')) {
            date = new Date(args.date.setMonth(args.date.getMonth() - 1));
        }
        if (args.view == 'Month') {debugger
            calendarObject = document.getElementById('calendar').ej2_instances[0];
            calendarObject.navigateTo('Month', date);
        }
    }
</script>

NOTE

View Sample in GitHub.