logo

/repo|v2.1.3

Class

new CalendarCore(container, options)

CalendarCore class

PARAMETERS
NameTypeDescription

container

stringElement

container element or selector.

options

object

calendar options. For more information, see Calendar options in guide.

PROPERTIES
NameTypeDescription

defaultView

string = "week"

Initial view type. Available values are: 'day', 'week', 'month'.

useFormPopup

boolean = false

Whether to use the default form popup when creating/modifying events.

useDetailPopup

boolean = false

Whether to use the default detail popup when clicking events.

isReadOnly

boolean = false

Whether the calendar is read-only.

usageStatistics

boolean = true

Whether to allow collect hostname and send the information to google analytics.
For more information, check out the documentation.

eventFilter

[ function ]

A function that returns true if the event should be displayed. The default filter checks if the event's property is true.

week

[ object ]

Week option of the calendar instance.

PROPERTIES
NameTypeDescription

startDayOfWeek

number = 0

Start day of the week. Available values are 0 (Sunday) to 6 (Saturday).

dayNames

[ Array ]

Names of days of the week. Should be 7 items starting from Sunday to Saturday. If not specified, the default names are used.
Default values are 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'.

workweek

boolean = false

Whether to exclude Saturday and Sunday.

showTimezoneCollapseButton

boolean = true

Whether to show the timezone collapse button.

timezonesCollapsed

boolean = false

Whether to collapse the timezones.

hourStart

number = 0

Start hour of the day. Available values are 0 to 24.

hourEnd

number = 24

End hour of the day. Available values are 0 to 24. Must be greater than .

narrowWeekend

boolean = false

Whether to narrow down width of weekends to half.

eventView

booleanArray.<string> = true

Determine which view to display events. Available values are 'allday' and 'time'. set to to disable event view.

taskView

booleanArray.<string> = true

Determine which view to display tasks. Available values are 'milestone' and 'task'. set to to disable task view.

collapseDuplicateEvents

booleanobject = false

Whether to collapse duplicate events. If you want to filter duplicate events and choose the main event based on your requirements, set and . For more information, see Options in guide.

month

object

Month option of the calendar instance.

PROPERTIES
NameTypeDescription

startDayOfWeek

number = 0

Start day of the week. Available values are 0 (Sunday) to 6 (Saturday).

dayNames

[ Array ]

Names of days of the week. Should be 7 items starting from Sunday to Saturday. If not specified, the default names are used.
Default values are 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'.

workweek

boolean = false

Whether to exclude Saturday and Sunday.

narrowWeekend

boolean = false

Whether to narrow down width of weekends to half.

visibleWeeksCount

number = 0

Number of weeks to display. 0 means display all weeks.

calendars

[ Array ]

Calendars to group events.

gridSelection

booleanobject = true

Whether to enable grid selection. or it's option. it's enabled when the value is and object and will be disabled when is true.

PROPERTIES
NameTypeDescription

enableDbClick

boolean

Whether to enable double click to select area.

enableClick

boolean

Whether to enable click to select area.

timezone

TimezoneOptions

Timezone option of the calendar instance. For more information about timezone, check out the Options in guide.

theme

Theme

Theme option of the calendar instance. For more information, see Theme in guide.

template

TemplateConfig

Template option of the calendar instance. For more information, see Template in guide.

Instance Methods

changeView(viewName)

Change current view type.

PARAMETERS
NameTypeDescription

viewName

string

The new view name to change to. Available values are 'month', 'week', 'day'.

EXAMPLES
// change to daily view
calendar.changeView('day');

// change to weekly view
calendar.changeView('week');

// change to monthly view
calendar.changeView('month');

clear()

Delete all events and clear view

EXAMPLES
calendar.clear();

createEvents(events)

Create events and render calendar.

PARAMETERS
NameTypeDescription

events

Array.<EventObject>

list of EventObject

EXAMPLES
calendar.createEvents([
  {
    id: '1',
    calendarId: '1',
    title: 'my event',
    category: 'time',
    dueDateClass: '',
    start: '2018-01-18T22:30:00+09:00',
    end: '2018-01-19T02:30:00+09:00',
  },
  {
    id: '2',
    calendarId: '1',
    title: 'second event',
    category: 'time',
    dueDateClass: '',
    start: '2018-01-18T17:30:00+09:00',
    end: '2018-01-19T17:31:00+09:00',
  },
]);

deleteEvent(eventId, calendarId)

Delete an event.

PARAMETERS
NameTypeDescription

eventId

string

event's id to delete

calendarId

string

The CalendarId of the event to delete

destroy()

Destroys the instance.

getDate()

Get current rendered date. (see TZDate for further information)

RETURNS:
{

TZDate

}

getDateRangeEnd()

End time of rendered date range. (see TZDate for further information)

RETURNS:
{

TZDate

}

getDateRangeStart()

Start time of rendered date range. (see TZDate for further information)

RETURNS:
{

TZDate

}

getElement(eventId, calendarId)

Get the DOM element of the event by event id and calendar id

PARAMETERS
NameTypeDescription

eventId

string

ID of event

calendarId

string

calendarId of event

RETURNS:
{

HTMLElement

} - event element if found or null
EXAMPLES
const element = calendar.getElement(eventId, calendarId);

console.log(element);

getEvent(eventId, calendarId)

Get an EventObject with event's id and calendar's id.

PARAMETERS
NameTypeDescription

eventId

string

event's id

calendarId

string

calendar's id of the event

RETURNS:
{

EventObjectnull

} - event. If the event can't be found, it returns null.
EXAMPLES
const event = calendar.getEvent(eventId, calendarId);

console.log(event.title);

getOptions()

Get current options.

RETURNS:
{

Options

} - The current options of the instance

getViewName()

Get current view name('day', 'week', 'month').

RETURNS:
{

string

} - current view name ('day', 'week', 'month')

move(offset)

Move the rendered date to the next/prev range.

PARAMETERS
NameTypeDescription

offset

number

The offset to move by.

EXAMPLES
// Move to the next month in month view.
calendar.move(1);

// Move to the next year in month view.
calendar.move(12);

// Move to yesterday in day view.
calendar.move(-1);

openFormPopup(event)

Open event form popup with predefined form values.

PARAMETERS
NameTypeDescription

event

EventObject

The predefined EventObject data to show in form.

render()

Render the calendar.

EXAMPLES
calendar.render();
// Re-render the calendar when resizing a window.
window.addEventListener('resize', () => {
  calendar.render();
});

renderToString()

For SSR(Server Side Rendering), Return the HTML string of the whole calendar.

RETURNS:
{

string

} - HTML string

scrollToNow(scrollBehavior)

Scroll to current time on today in case of daily, weekly view.
Nothing happens in the monthly view.

PARAMETERS
NameTypeDescription

scrollBehavior

= 'auto'

EXAMPLES
function onNewEvents(events) {
  calendar.createEvents(events);
  calendar.scrollToNow('smooth');
}

setCalendarColor(calendarId, colorOptions)

Change color values of events belong to a certain calendar.

PARAMETERS
NameTypeDescription

calendarId

string

The calendar ID

colorOptions

object

The color values of the calendar

PROPERTIES
NameTypeDescription

color

string

The text color of the events

borderColor

string

Left border color of events

backgroundColor

string

Background color of events

dragBackgroundColor

string

Background color of events during dragging

EXAMPLES
calendar.setCalendarColor('1', {
    color: '#e8e8e8',
    backgroundColor: '#585858',
    borderColor: '#a1b56c',
    dragBackgroundColor: '#585858',
});
calendar.setCalendarColor('2', {
    color: '#282828',
    backgroundColor: '#dc9656',
    borderColor: '#a1b56c',
    dragBackgroundColor: '#dc9656',
});
calendar.setCalendarColor('3', {
    color: '#a16946',
    backgroundColor: '#ab4642',
    borderColor: '#a1b56c',
    dragBackgroundColor: '#ab4642',
});

setCalendars(calendars)

Set calendar list.

PARAMETERS
NameTypeDescription

calendars

Array.<CalendarInfo>

list of calendars

setCalendarVisibility(calendarId, isVisible)

Set events' visibility by calendar ID

PARAMETERS
NameTypeDescription

calendarId

stringArray.<string>

The calendar id or ids to change visibility

isVisible

boolean

If set to true, show the events. If set to false, hide the events.

setDate(date)

Move to specific date.

PARAMETERS
NameTypeDescription

date

DatestringnumberTZDate

The date to move. it should be eligible parameter to create a instance if is string or number.

EXAMPLES
calendar.on('clickDayName', (event) => {
  if (calendar.getViewName() === 'week') {
    const dateToMove = new Date(event.date);

    calendar.setDate(dateToMove);
    calendar.changeView('day');
  }
});

setOptions(options)

Set options of calendar. For more information, see Options in guide.

PARAMETERS
NameTypeDescription

options

Options

The options to set

setTheme(theme)

Set the theme of the calendar.

PARAMETERS
NameTypeDescription

theme

Theme

The theme object to apply. For more information, see Theme in guide.

EXAMPLES
calendar.setTheme({
  common: {
    gridSelection: {
      backgroundColor: '#333',
    },
  },
  week: {
    nowIndicatorLabel: {
      color: '#00FF00',
    },
  },
  month: {
    dayName: {
      borderLeft: '1px solid #e5e5e5',
    },
  },
});

today()

Move to today.

EXAMPLES
function onClickTodayBtn() {
  calendar.today();
}

updateEvent(eventId, calendarId, changes)

Update an event.

PARAMETERS
NameTypeDescription

eventId

string

ID of an event to update

calendarId

string

The calendarId of the event to update

changes

EventObject

The new EventObject data to apply to the event

EXAMPLES
calendar.on('beforeUpdateEvent', function ({ event, changes }) {
  const { id, calendarId } = event;

  calendar.updateEvent(id, calendarId, changes);
});
Resizable