Use knockout and ajax to load/refresh the scheduler?

Hello,

We are evaluating the scheduler for our project, but we have stumbled probklems doing something I expected to be pretty straight forward.

We need to load new data and refresh the scheduler based on two events:

  • The user clicks Prev/Next
  • The user changes a selection in an pulldown on the page (external from scheduler)

We are using knockout to trigger a function when

  • An observable is changed from the onBeforeViewChange handler
  • An observable is changed from the external select/dropdown

In both cases we call a function:

        var reload = function (newValue) {

            // Get date from view model
            var lastDate = schedulerModelInstance.lastDate();

            $.ajax({
                url: "../Fravar/GetLessonsForResource",
                data: {                    
                    dateFrom: lastDate.toISOString(),
                    days: schedulerModelInstance.days,
                    resourceType: schedulerModelInstance.selectedResourceType(),
                    resourceId:  schedulerModelInstance.selectedResourceId(),        
                },
                success: function(data) {
                    scheduler.parse(data, "json");
                    scheduler.updateView();
                },
                dataType: "text"
            });
        };

This does not work. No error messages, and no new events in the scheduler. I have verified that the data we get in the ajax call looks ok.

"[{"id":"1","text":"Gruppe ENG001","start_date":"2013-08-09 09:00:00","end_date":"2013-08-09 09:45:00"},{"id":"2","text":"Gruppe MAT009","start_date":"2013-08-09 10:00:00","end_date":"2013-08-09 10:45:00"},{"id":"3","text":"Gruppe NOR002","start_date":"2013-08-09 10:00:00","end_date":"2013-08-09 10:45:00"}]"

We have also tried parsing the result of $.getJSON(), or using scheduler.load(customUrl). Same result (no new events and no errors), even though the data on the wire looks ok.

Any and all help to make this work is greatly appreciated as right now we are dead in the water.


Thor Arne Johansen
Oppad AS

Scheduler can parse data from the string, and format of json response looks fine
The problem may be in date format, which date format is configured for the scheduler

Try to change the code as

scheduler.config.xml_date="%Y-%m-%d %H:%i"; scheduler.parse(data, "json"); scheduler.updateView();

Yes that worked! Thanks a lot.

(Unbelievable that I did not catch it myself since I did check and explitly format the dates going over the wire).


Thor Arne Johansen
Oppad AS