Custom Header

You can customize how the header of calendar looks and how the components are arranged. Besides that you can also add custom functionality, like a segmented control that lets people switch between week and month view.

Use the renderCalendarHeader option for passing a custom header layout. There are predefined components - shorthands if you will - that can be used to assemble the header:

  • Navigation component - <div mbsc-calendar-nav></div>
  • Today button - <button mbsc-calendar-today></button>
  • Previous month button - <button mbsc-calendar-prev></button>
  • Next month button - <button mbsc-calendar-next></button>
Download and try example

Demo

Default header

The default header contains the two arrows on the far-right for previous and next months, while the current month indicator with the mbsc-calendar-nav component is placed to the far-left.

$('#default').mobiscroll().datepicker({
    controls: ['calendar']
    calendarType: 'week',
    calendarSize: 2
}
Custom header arrangement

You can reorder the controls and place the mbsc-calendar-nav in the middle with the two arrows - mbsc-calendar-prev and mbsc-calendar-next - to the sides.

$('#header-order').mobiscroll().datepicker({
    controls: ['calendar'],
    renderCalendarHeader: function () {
        return '<div mbsc-calendar-prev class="custom-prev"></div>' +
            '<div mbsc-calendar-nav class="custom-nav"></div>' +
            '<div mbsc-calendar-next class="custom-next"></div>';
    }
}
Add a today button

You can also add a custom component, like a mbsc-calendar-today button.

$('#today-button').mobiscroll().datepicker({
    controls: ['calendar'],
    renderCalendarHeader: function () {
        return '<div mbsc-calendar-nav></div>' +
            '<div class="custom-buttons">' +
            '<div mbsc-calendar-prev></div>' +
            '<div mbsc-calendar-today></div>' +
            '<div mbsc-calendar-next></div>' +
            '</div>';
    }
}
Switch between week and month view

Use a segmented component for creating a view switcher.

var myCalendar = $('#custom-header').mobiscroll().datepicker({
    controls: ['calendar'],
    calendarType: 'week',
    calendarSize: 2,
    renderCalendarHeader: function () {
        return '<div mbsc-calendar-nav class="custom-view-nav"></div><div class="custom-view">' +
            '<label><input data-icon="material-date-range" mbsc-segmented type="radio" name="view" value="week" class="view-change" checked></label>' +
            '<label><input data-icon="material-event-note" mbsc-segmented type="radio" name="view" value="month" class="view-change"></label></div>' +
            '<div mbsc-calendar-prev></div>' + 
            '<div mbsc-calendar-next></div>';
    }
}
                                
$('.view-change').change(function (ev) {
	switch (ev.target.value) {
		case 'week':
			myCalendar.setOptions({
				calendarType: 'week'
			});
			break;
		case 'month':
			myCalendar.setOptions({
				calendarType: 'month'
			});
			break;
	}
});
Preview the selection

Above all that you can give instructions or show the selected {value} in the header

$('#header-value').mobiscroll().datepicker({
    controls: ['calendar'],
    calendarType: 'week',
    calendarSize: 2,
    headerText: 'You selected {value}'
}

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.