I want to show events in webix scheduler UNIT view But events are not getting displayed on calendar. My url is fine and receiving a successful response from the server with the data I need for the events. The response contains an array of events, and each event object has properties such as id
, title
, start
, end
, and url
.
JSON response and code
var data = {
"response": "success",
"events": [
{
"id": 46,
"url": "",
"title": "Jeremy Madison",
"start": "2023/09/28 09:45:00 AM",
"end": "2023/09/28 09:45:00 AM",
"extendedProps": {
"calendar": "business",
"model": {
"id": 46,
"appointment_type": "medical",
"user_id": 1,
"service_id": 1,
"company_id": 1,
"patient_id": 20,
"location_id": 1,
"time_id": null,
"start": "2023-09-28 09:30:00",
"end": "2023-09-28 09:45:00",
"time": "9:30 AM",
"duration": "15",
"allDay": 0,
"appointment_alert": null,
"frequency": "1 day",
"status": 0,
"created_at": "2023-08-04 15:08:41",
"updated_at": "2023-08-04 15:08:41",
"policy_holder": null,
"location": "peshawar",
"code": "34214",
"payer_name": null,
"mobile_no": "+1 (907) 769-9091\n",
"dob": "2006-10-23",
"admin_sex": "female",
"clinician_name": "Sudais Khan",
"patient_name": "Jeremy Madison"
}
}
}
]
}
webix.ready(function () {
webix.CustomScroll.init();
var id = 1;
var apiUrl = "schedules?nid=" + id;
var eventsLoaded = false;
var scheduler = webix.ui({
view: "scheduler",
container: "my_schedules",
id: "myScheduler",
width: 1000,
height: 1000,
save: "rest->" + apiUrl,
url: apiUrl,
monthSelect: true,
weekHeader: true,
events: new webix.DataCollection({
scheme: {
$init: function (obj) {
obj.start_date = webix.Date.isDate(obj.start)
? obj.start
: webix.Date.strToDate("%Y/%m/%d %H:%i")(obj.start);
obj.end_date = webix.Date.isDate(obj.end)
? obj.end
: webix.Date.strToDate("%Y/%m/%d %H:%i")(obj.end);
},
},
}),
on: {
onBeforeEventSave: function (id, data, update) {
if (update) {
data.start = webix.Date.dateToStr("%Y/%m/%d %H:%i")(data.start_date);
data.end = webix.Date.dateToStr("%Y/%m/%d %H:%i")(data.end_date);
} else {
data.start = webix.Date.dateToStr("%Y/%m/%d %H:%i")(data.start_date);
data.end = webix.Date.dateToStr("%Y/%m/%d %H:%i")(data.end_date);
}
},
},
});
scheduler.attachEvent("onViewChange", function (newView) {
if (!eventsLoaded && newView === "month") {
scheduler.clearAll();
scheduler.load(apiUrl, "json");
eventsLoaded = true;
}
});
});
from Events are not loading into the webix scheduler calendar
No comments:
Post a Comment