I'm currently trying to figure out how to post data to my API when an event is created using the editor window. I use Ajax to retrieve content already as shown below;
const ajax: Ajax = new Ajax(
"https://localhost:3486/api/CalendarEvents?StartDate=" + startDate + "&EndDate=" + endDate,
"GET",
true
);
ajax.send().then();
ajax.onSuccess = (data: string): void =>
{
this.scheduler.eventSettings = {
dataSource: JSON.parse(data).map((value, index) => ({
id: index,
Subject: value.title,
StartTime: value.startDate,
EndTime: value.startDate
})),
fields: {
}
};
};
ajax.onFailure = (): void =>
{
};
Furthermore, how do I get the currently selected date range when the user changes the date on the scheduler via view or date navigation.
onActionComplete(args: ActionEventArgs): void {
if (args.requestType == "dateNavigate") {
// how to get current date range ?
}
}
[UPDATE] Found how to get the currently selected date range:
onActionComplete(args: ActionEventArgs): void {
if (args.requestType === "viewNavigate" || args.requestType === "dateNavigate") {
const currentDates: Date[] = this.scheduleObj.getCurrentViewDates();
const startDate = currentDates[0];
const endDate = currentDates[currentDates.length - 1];
}
}