jQuery UI Widgets Forums Scheduler addAppointment not using given id

This topic contains 4 replies, has 2 voices, and was last updated by  svetoslav_borislavov 3 weeks, 5 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • addAppointment not using given id #132220

    vingy
    Participant

    I’m trying to add a placeholder appointment with a specific id that I can manipulate/delete later, but I’m finding that the appointment is created with everything except the id. It’s being created with a generated id like 3120-26-20-18-21. I’m also pulling in an external data source for appointments and the ids work fine from that. Any help is appreciated.

    here’s my data fields

        appointmentDataFields: {
            from: "start",
            to: "end",
            id: "id",
            description: "description",
            subject: "subject",
            draggable: "draggable",
            resizable: "resizable",
        },

    here’s the code adding the appointment

    //add placeholder appointment
        let placeholder_appointment = {
            id: "new",
            description: 'new',
            subject: 'new',
            start: start_date,
            end: end_date,
            draggable: false,
            resizable: false,
        };
        dest_schedule.jqxScheduler('addAppointment', placeholder_appointment);

    here’s the source

    dest_schedule_source =
        {
            datatype: 'json',
            datafields: [
                { name: 'id', type: 'string' },
                { name: 'description', type: 'string' },
                { name: 'subject', type: 'string' },
                { name: 'start', type: 'date' },
                { name: 'end', type: 'date' },
            ],
            id: 'id',
        };
    addAppointment not using given id #132224

    Hi,

    The only way to do this is to set the dataSource with the new appointment added.
    If you use the ‘addAppointment’ method the scheduler will generate ids, so just set new dataSource

    I hope this helps!

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

    addAppointment not using given id #132230

    vingy
    Participant

    Ok, I’ve built the placeholder into the my data source and it gets get created with the correct id. Now I’m trying to update the to and from dates for the appointment. However, when I try to update the appointment date it disappears. I’ve verified through logging that the appointment still exists and has the correct date, but is no longer visible.

    The appointment is created with
    from: Thu Jan 12 2023 06:00:00 GMT-0600 (Central Standard Time)
    to: Thu Jan 12 2023 06:30:00 GMT-0600 (Central Standard Time)

    And I’m using this code to change it

        let start_date = new Date("2023-01-12 06:30:00");
        let end_date = new Date("2023-01-12 07:00:00");
    
        //update placeholder appointment
        dest_schedule.jqxScheduler('beginAppointmentsUpdate');
        dest_schedule.jqxScheduler('setAppointmentProperty', 'new', 'from', start_date);
        dest_schedule.jqxScheduler('setAppointmentProperty', 'new', 'to', end_date);
        dest_schedule.jqxScheduler('endAppointmentsUpdate');
    
        console.log(dest_schedule.jqxScheduler('getAppointmentProperty', 'new', 'from'));
        console.log(dest_schedule.jqxScheduler('getAppointmentProperty', 'new', 'to'));

    The logging shows that the dates have changes, but the appointment is gone from the scheduler.

    If I try to call ensureAppointmentVisible after the above code, it crashes the page.

    • This reply was modified 3 weeks, 5 days ago by  vingy.
    addAppointment not using given id #132232

    vingy
    Participant

    Nevermind, I needed to convert the dates to jqx date objects. Works for me now.

        let jqx_start_date = new $.jqx.date(start_date);
        let jqx_end_date = new $.jqx.date(end_date);
    • This reply was modified 3 weeks, 5 days ago by  vingy.
    • This reply was modified 3 weeks, 5 days ago by  vingy.
    addAppointment not using given id #132236

    Hi,

    Thank you for the feedback!
    If you have any additional questions, do not hesitate to contact us!

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

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

You must be logged in to reply to this topic.