getState
returns the reactive state object of Scheduler
object getState();
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) - a JavaScript Date object;
- mode (string) - the current display mode;
- readonly (boolean) - the current readonly state (true or false);
- selected (object) - the currently selected event. Contains the following fields:
- id (string, number) - the event ID;
- date (string) - (for recurring events) the ID of a particular recurrence;
- node (object) - the HTML node of the selected event (recurrence), if the event is selected by a click.
Methods
- $observe (function) - a handler to listen to changes in the current state of Scheduler. It takes 2 parameters:
- prop (string) - a reactive property whose changes you want to listen to;
- handler (function) - a function to execute when changes are made. It takes a single argument:
- value (any) - the current value of the reactive property. The type of the value (string, array, etc.) depends on the reactive property being observed.
- $batch (function) - allows setting several properties at once. It takes a single parameter:
- props (object) - an object containing pairs of property names and values to set.
For example, you can listen to the display mode changes as follows:
state.$observe("mode", v => {
// custom logic
});
Or set several properties in a batch:
// switches to the "week" view and enables the readonly mode
state.$batch({
mode: "week", readonly: true
});
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support,
connect with other developers, and share your feedback there.