Scheduler widget expects a backend server to fetch events and calendars. You can provide a link to it by the url setting:
webix.ui({
view: "scheduler",
url:"http://localhost:3200/"
});
Scheduler will load and save data using the following URLs:
Sample backend for Scheduler is available for downloading.
If you do not have a backend server, you can customize the methods of the Backend service and provide client-side data as a promise.
Backend service is a server-side model that contains methods for sending requests. They are called by the Operations service when data needs to be loaded or saved.
Check out the full list of methods below.
To change data requests, get and process the responses you can:
class MyBackend extends scheduler.services.Backend {
// define and override methods here
}
webix.ui({
view: "scheduler",
url:"http://localhost:3200/",
override: new Map([[scheduler.services.Backend, MyBackend]]),
});
You can send AJAX requests to your server by using the needed URLs, e.g.:
Adding an event
class MyBackend extends scheduler.services.Backend {
addEvent(event) {
return webix.ajax.post("//localhost:3200/events", event)
.then(res => res.json());
}
}
If you need to fill Scheduler with client-side data, you can return it as a promise inside the following methods:
Client-side data
class MyBackend extends scheduler.services.Backend {
events() {
return webix.promise.resolve(events);
}
calendars() {
return webix.promise.resolve(calendars);
}
}
Related sample: Scheduler: Local Data
See the required format of the incoming data.
Below you can find descriptions of the following methods:
Is used by other methods for preparing URLs for server requests.
Parameters:
Returns: the full path.
Is called upon widget initialization.
Parameters:
{
from: "2018-05-21 00:00:00",
to: "2018-05-22 00:00:00"
}
Returns: a promise that resolves with an array of events (all or for a specified date period).
Request:
GET http://localhost:3000/events
// dynamic loading
GET http://localhost:3000/events?from=2020-10-01%2000%3A00%3A00&to=2020-11-01%2000%3A00%3A00
Response:
The server returns an array with events data objects:
[
{"start_date":"2018-06-08 17:00:00","end_date":"2018-06-08 20:00:00",
"text":" Zentralstadion - Leipzig ","details":" Leipzig, GER ",
"color":"#91E4A6","calendar":2,"id":"1"},
{"recurring":"FREQ=WEEKLY;BYDAY=MO","text":"Meeting",
"start_date":"2018-05-21 20:00:00","end_date":"2018-05-21 21:00:00",
"all_day":"0","calendar":1,"color":"#D2FB9E",
"details":"Starbucks","id":"ftwMT7mkIZPJIMmO", section: "1", units: "3"},
// other events
]
Adds a new event to the server.
Parameters:
Returns: a promise that resolves with an object containing ID of the new event.
Request:
POST http://localhost:3000/events
Form Data
recurring: FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1
text: Meeting
start_date: 2018-05-21 20:00:00
end_date: 2018-05-21 21:00:00
all_day: 0
calendar: 1
color: #997CEB
details: Meeting with Dave at Starbucks
sections: 1
units: 3
You can read more about the recurring string rules in the iCal specification.
Response:
The server returns an object containing ID of the new event.
{id: "mY7VoF4uLsxHaJqf"}
Updating a specified event.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/events/mY7VoF4uLsxHaJqf
Form Data
// non-recurring
"start_date":"2020-10-10 11:35:00","end_date":"2020-10-10 14:35:00"
"mode": "all"
// for recurring
"recurring":"FREQ=DAILY;INTERVAL=1;UNTIL=20201009T000000Z"
"recurring_update_date": some date
"recurring_update_mode": "next"
"mode": next
"date": 2020-10-09 00:00:00
You can read more about the recurring string rules in the iCal specification.
Removes a specified event.
Parameters:
Returns: a promise.
Request:
DELETE http://localhost:3000/events/mY7VoF4uLsxHaJqf
Is called when Scheduler is switched to the Timeline mode.
Returns: a promise that resolves with an array of all sections.
Request:
GET http://localhost:3000/sections
Response:
The server returns an array of the sections data objects.
[
{"text":"Section 1","id":"1"},
{"text":"Section 2","id":"2"},
// other sections
]
Is called when Scheduler is switched to the Units mode.
Returns: a promise that resolves with an array of all units.
Request:
GET http://localhost:3000/units
Response:
The server returns an array of the units data objects.
[
{"id":"1"," value":"Sports"},
{"id":"2", "value":"Social activities"},
{"id":"3","value":"Celebrations"}
]
Is called upon widget initialization.
Returns: a promise that resolves with an array of all calendars (event groups).
Request:
GET http://localhost:3000/calendars
Response:
The server returns an array of the calendars data objects.
[
{"text":"Personal","color":"#997CEB","active":1,"id":"1"},
{"text":"Public","color":"#01C2A5","active":1,"id":"2"},
{"text":"Birthdays","color":"#D2FB9E","active":0,"id":"3"},
{"text":"Holidays","color":"#F68896","active":0,"id":"4"},
// other if any
]
Adds a new calendar to the server.
Parameters:
Returns: a promise that resolves with an object containing ID of the new calendar.
Request:
POST http://localhost:3000/calendars
Form Data
text: (no title)
color: #997CEB
active: 1
Response:
The server returns an object containing the ID of the new calendar.
{id: "nNQcTUFtOCZQXP2F"}
Updates a specified calendar.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/calendars/nNQcTUFtOCZQXP2F
Form Data
id: nNQcTUFtOCZQXP2F
text: Legends
color: #F7CC34
active: 1
Removes a specified calendar.
Parameters:
Returns: a promise.
Request:
DELETE http://localhost:3000/calendars/nNQcTUFtOCZQXP2F
Back to top