jQWidgets Forums

jQuery UI Widgets Forums Scheduler Set Appointment Date From Controller

This topic contains 1 reply, has 1 voice, and was last updated by  RoyClem 5 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Set Appointment Date From Controller #107813

    RoyClem
    Participant

    All I’m trying to do is set the Scheduler start and end dates from backend code so the appointments show correctly after the Scheduler loads.

    I’m trying to set an appointment for 01/02/2020 in a C# Controller (code below).

    The date today is 1/11/2020.

    No matter how I format the start and end dates, the 1/2/2020 appointment ALWAYS shows on the current date.

    How do I specify or format the date so that the appointment shows correctly in the Scheduler on 1/2/2020?

    The code below is my latest, failed, attempt.

    client code:
    var source =
    {
    url: ‘/Calendar/GetCalendarEvents/’,
    dataType: “json”,
    type:’GET’,
    dataFields: [
    { name: ‘id’, type: ‘string’ },
    { name: ‘description’, type: ‘string’ },
    { name: ‘location’, type: ‘string’ },
    { name: ‘subject’, type: ‘string’ },
    { name: ‘start’, type: ‘date’, format: “MM-dd-yyyy HH:mm” },
    { name: ‘end’, type: ‘date’, format: “MM-dd-yyyy HH:mm” },
    { name: ‘background’, type: ‘string’ },
    { name: ‘allDay’, type: ‘boolean’ },
    { name: ‘status’, type: ‘string’ },
    ],
    id: ‘id’
    };

    $(“#scheduler”).jqxScheduler({
    source: source,
    view: ‘monthView’,
    showLegend: false,
    ready: function () {
    $(“#scheduler”).jqxScheduler(‘ensureAppointmentVisible’, ‘id1’);
    },
    resources:
    {
    colorScheme: “scheme05”,
    dataField: “calendar”,
    source: new $.jqx.dataAdapter(source)
    },
    rendered: function () {
    // highlights current date
    $(‘[data-date=”‘ + new $.jqx.date().toString(“yyyy-MM-dd 00:00:00″) + ‘”]’).css(“background”, “#f8efc8”);
    },
    editDialogDateTimeFormatString: ‘MM-dd-yyyy HH:mm’,
    editDialogDateFormatString: ‘MM-dd-yyyy’,
    views:
    [
    ‘dayView’,
    ‘weekView’,
    ‘monthView’
    ]
    });

    Controller code:

    public JsonResult GetCalendarEvents()
    {
    var apt = new Appointment
    {
    id = “id6”,
    description = “Frank’s birthday party”,
    location = “San Antonio, Texas”,
    subject = “Birthday”,
    start = DateTime.Parse(“01/02/2020 12:00:00”),
    end = DateTime.Parse(“01/02/2020 11:59:00”),
    background = “#0000FF”,
    allDay = true,
    status = “tentative”
    };

    return Json(apt, JsonRequestBehavior.AllowGet);
    }

    Set Appointment Date From Controller #107815

    RoyClem
    Participant

    Apparently, I did not fully configure the calendar.

    After I configured the scheduler based on an example in the demos folder from the distribution, the dates correctly showed.

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

You must be logged in to reply to this topic.