DayPilot.Calendar.update

The update() method updates and redraws the component. Two update modes are supported:

1. You can make the changes by changing the properties directly:

dp.viewType = "Resources";
dp.update();

2. You can pass a set of changes using the options parameter:

dp.update({viewType: "Resources"});

This method can be called before init(). In that case it will only set the properties specified using the options parameter which will be applied during the init() call.

This method cannot be called after the component has been disposed using dispose(). In that case, an exception will be thrown.

Declaration

DayPilot.Calendar.update([options]);

Parameters

  • options - object with properties and events to be updated (object)

The options object can specify any of the standard properties and event handlers.

Special Properties

The following options properties have a special meaning:

  • columns - specifies the columns array (will be translated to columns.list); since 2019.2.3845
  • events - specifies the events array (will be translated to events.list); if this is the only property a partial update will be performed (see Optimized Update below)
  • scrollToHour - the Calendar will scroll vertically to the specified hour after update

Optimized Update

An optimized partial update will be performed if the only property in the options object is one of these properties:

  • events (since 2019.1.3531)

Example:

dp.update({events: [ { id: 1, start: "2020-10-01T12:00:00", end: "2020-10-01T14:00:00", text: "Event 1" } ]});

Examples

Loading events using the options parameter:

var 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});

Changing the calendar view type:

dp.viewType = "Day";
dp.update();