I'm currently grappling with how to send data to my API whenever a new event is created using the editor window. My approach so far involves using Ajax to fetch content, as seen in the code snippet 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 =>
{
};
Additionally, I am curious about how to obtain the currently selected date range when the user modifies the date on the scheduler through view or date navigation.
onActionComplete(args: ActionEventArgs): void {
if (args.requestType == "dateNavigate") {
// How can the current date range be retrieved?
}
}
[UPDATE] I have now discovered how to retrieve the presently 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];
}
}