jQWidgets Forums
jQuery UI Widgets › Forums › Scheduler › Pull Data from Backend into the Schedular
Tagged: schedular
This topic contains 3 replies, has 2 voices, and was last updated by Hristo 5 years, 4 months ago.
-
Author
-
Hi Everyone,
I’m trying to add the data from my backen into the appointments array. But after I loop the array to put the required data into the appointment objects, I can’t see the schedular anymore..
Here’s my code, I hope someone can help meconst appointments = []; var buchungArray = JSON.parse(<%=buchungen%>); for(var i=0; i < buchungArray.length; i++) { var appointment = {}; var monat = 1 + buchungArray[i].from.getMonth(); var von = -1 + buchungArray[i].from.getHours(); var vonMin = buchungArray[i].from.getMinutes(); var bisMonat = 1 + buchungArray[i].from.getMonth(); var bis = -1 + buchungArray[i].to.getHours(); var bisMin = buchungArray[i].to.getMinutes(); appointment[i] = { calendar: buchungArray[i].tor, start: new Date(buchungArray[i].from.getDate(), monat, buchungArray[i].from.getDay(), von, vonMin, 0), end: new Date(buchungArray[i].to.getDate(), bisMonat, buchungArray[i].to.getDay(), bis, bisMin, 0) } appointments.push(appointment[i]); console.log(appointments); } // prepare the data var source = { dataType: "array", dataFields: [ { name: 'calendar', type: 'number' }, { name: 'start', type: 'date' }, { name: 'end', type: 'date' } ], localData: appointments }; var adapter = new $.jqx.dataAdapter(source); $("#scheduler").jqxScheduler({ date: new $.jqx.date(2015, 10, 23), width: 1050, height: 600, dayNameFormat: "abbr", source: adapter, view: 'dayView', showLegend: true, ready: function () { $("#scheduler").jqxScheduler('ensureAppointmentVisible', 'id1'); }, resources: { colorScheme: "scheme09", dataField: "calendar", orientation: "horizontal", source: new $.jqx.dataAdapter(source) }, appointmentDataFields: { from: "start", to: "end", id: "id", description: "about", subject: "subject", resourceId: "calendar" }, views: [ { type: "dayView", showWeekends: false, timeRuler: { hidden: false } }, { type: "weekView", showWeekends: false, }, { type: "monthView", showWeekends: false } ] });
Hello Mert1296,
Is there any error message in the console?
Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comHi Hristo,
no there are no errors..
Best regards,
MertHello Mert,
It happens because the parsing of the dates is not correct.
Or just add dates with not expected years.
I mean if you change “buchungArray[i].from.getDate()” option which expect full year tobuchungArray[i].from.getFullYear()
option.
I hope this will help.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.