The update() method updates and redraws the JavaScript Calendar component.
DayPilot.Calendar.update([options]);options (object) - optional object with properties and event handlers to update
You can update the component in two ways: modify properties directly on the DayPilot.Calendar instance and then call update(), or pass the changes using the options parameter.
The options object can include any of the standard properties and event handlers.
This method can be called before init(). In that case, it only sets the properties specified using the options parameter, and the Calendar component is rendered when you call init().
This method cannot be called after the component has been disposed using dispose(). In that case, an exception is thrown.
The following options properties have a special meaning:
columns - specifies the columns array and is translated to columns.list since 2019.2.3845
events - specifies the events array and is translated to events.list; if this is the only property, an optimized partial update is performed
scrollToHour - scrolls vertically to the specified hour after the update
zoom - sets the zoom level index since 2023.1.5540
An optimized partial update is performed when options contains only events (since 2019.1.3531).
Update a property directly on the calendar instance:
dp.viewType = "Resources";
dp.update();Pass the changes using the options parameter:
dp.update({viewType: "Resources"});Load events using the options parameter:
const data = [
{
id: 1,
start: DayPilot.Date.today().addHours(10),
end: DayPilot.Date.today().addHours(11),
text: "Event 1"
},
{
id: 2,
start: DayPilot.Date.today().addHours(13),
end: DayPilot.Date.today().addHours(16),
text: "Event 2"
}
];
dp.update({events: data});Change the calendar view type:
dp.viewType = "Day";
dp.update();