jQWidgets Forums

jQuery UI Widgets Forums Scheduler make 2 calls to the server to get data?

This topic contains 4 replies, has 2 voices, and was last updated by  wzjack 9 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • wzjack
    Participant

    Hi below is my example of getting data from server by using the jqx.dataAdapter, however it looks like it is making multiple calls to get the same data
    If I only assign the source under resources, no data is show. What is the difference between source and resources? The documentation didn’t show clearly about what they are and why we have to set both in order to make it work. Thanks

    var source = {
    dataType: “json”,
    dataFields: [
    { name: ‘Description’, type: ‘string’ },
    { name: ‘StartDate’, type: ‘date’, format: “yyyy-MM-dd HH:mm” },
    { name: ‘EndDate’, type: ‘date’, format: “yyyy-MM-dd HH:mm” },
    { name: ‘ID’, type: ‘string’ },
    ],
    id: ‘ID’,
    url: ‘LoadAppointmentByRange’,
    data: {
    dateFrom: weekStartDate,
    dateTo: weekEndDate
    }
    };

    var dataAdapter = new $.jqx.dataAdapter(source,
    {
    beforeSend: function (xhr) {
    console.log(123);//testing it print twice….
    }
    });

    $(‘#appointmentScheduler’).jqxScheduler({
    date: new $.jqx.date(‘todayDate’),
    width: 1200,
    height: 700,
    source: dataAdapter, //<———-this makes the first call to the server
    view: ‘weekView’,
    showLegend: false,
    legendPosition: ‘bottom’,
    appointmentTooltips: true,
    theme: ‘summer’,
    dayNameFormat: “abbr”,
    touchDayNameFormat: “abbr”,
    resources:
    {
    colorScheme: “scheme05”,
    dataField: “ID”,
    source: dataAdapter //<———-this makes the first call to the server
    },
    appointmentDataFields:
    {
    from: “StartDate”,
    to: “EndDate”,
    id: “ID”,
    description: “Description”,
    resourceId: “ID”
    },
    views:
    [`
    { type: ‘dayView’ },
    { type: ‘weekView’ },
    { type: ‘monthView’ },
    { type: ‘agendaView’ }
    ]
    });


    Peter Stoev
    Keymaster

    Hi wzjack,

    Resources and Source are populated from Different Data Sources. This means that 2 Server calls are absolutely required. Another requirement is the adapters for the Resources and Source are different.

    Regards,
    Peter Stoev


    wzjack
    Participant

    Hi Peter,

    Thanks for your reply. I am just wondering in terms of performance, is there any way to make only one call to the server? So far, I can only think of doing a separate Ajax call then assign to the localdata property inside the source file.

    Also, what resources and sources are used for? what data are they populated? Correct me if I am wrong, resources is used for legend, different types of color for each appointment, and sources is for the actual appointment data.

    Once again, thanks for your reply.

    Best regards,

    Jack


    Peter Stoev
    Keymaster

    Hi wzjack,

    Resources and Source data can be different. You can have 3 resources “Room 1, Room 2 and Room 3” and 1 appointment in Room 1 i.e you should have 2 separate data sources.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    wzjack
    Participant

    Oh now I got it.

    Thank you so much. 🙂

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

You must be logged in to reply to this topic.