jQWidgets Forums

jQuery UI Widgets Forums Scheduler Pull Data from Backend into the Schedular

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 5 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Pull Data from Backend into the Schedular #107846

    Mert1296
    Participant

    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 me 🙂

    const 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  }
                        ]
                });
    Pull Data from Backend into the Schedular #107868

    Hristo
    Participant

    Hello Mert1296,

    Is there any error message in the console?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

    Pull Data from Backend into the Schedular #107882

    Mert1296
    Participant

    Hi Hristo,

    no there are no errors..

    Best regards,
    Mert


    Hristo
    Participant

    Hello 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 to buchungArray[i].from.getFullYear() option.
    I hope this will help.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.