getState

returns the reactive state object of Scheduler

object getState();
objectstate object

Example

// returns the current state of Scheduler
const state = $$("scheduler").getState();
 
// switches to the "week" display mode
state.mode = "week";

Related samples

Details

The returned state object contains the following properties and methods:

{
  active: [...], date: new Date(),
  mode: "month", readonly: false,
  selected: {id: "30", date: "1526974200000_30"}
}

Properties

  • active (array) - an array with IDs of active calendars;
  • date (object) - JavaScript Date object;
  • mode (string) - current display mode;
  • readonly (boolean) - current readonly state (true or false);
  • selected (object) - an event being selected currently. Contains ID of the event and ID of a particular recurrence.

Methods

  • $observe (function) - a handler to listen to changes in the current state of Scheduler. It takes 2 parameters:
    • prop (string) - a reactive property to listen changes of
    • handler (function) - a function to execute when changes are made. It takes the only argument:
      • value (any) - the current value of the reactive property. The type of the value (string, array, etc) depends on a reactive property being observed.
  • batch (function)- allows to set several properties at once. Takes the only parameter:
    • props (object) - an object containing the pairs of the property name and the value to set.

For example, you can listen to the selection changes as:

state.$observe("mode", v =>
   // custom logic
);

Or set several properties in a batch:

// switches to the "week" view and switches readonly on
state.$batch({
   mode:"week", readonly: true
});
Back to top