0

I'm probably just missing something but I'm trying to populate kendo scheduler with a a provided data object. My data object is loaded first, then I load and initialize the kendo scheduler. Note, that everything works on the scheduler except loading the initial data set. Bellow is my data:

var _data = [{
    eventID: 7,
    title: "Physical therapy.",
    start: new Date("2013/06/12 13:00"),
    end: new Date("2013/06/12 14:30"),
    pending:true,
    recurrenceRule: "",
    recurrenceException: "",
    description: "Take my mom to her physical therapy.",
    isAllDay:false,
    ownTimeSlot:true,
    careAssistantId: 5,
    clientId: 6
},{
    eventID: 8,
    title: "Group meeting.",
    start: new Date("2013/06/13 12:00"),
    end: new Date("2013/06/13 13:30"),
    pending:false,
    recurrenceRule: "",
    recurrenceException: "",
    description: "Take my brother to his group meeting.",
    isAllDay:false,
    ownTimeSlot:true,
    careAssistantId: 5,
    clientId: 6
},{
    eventID: 9,
    title: "Make dinner.",
    start: new Date("2013/06/13 18:00"),
    end: new Date("2013/06/13 20:30"),
    pending:true,
    recurrenceRule: "FREQ=DAILY;INTERVAL=2;COUNT=8",
    recurrenceException: "",
    description: "Make dinner for my mom.",
    isAllDay:false,
    ownTimeSlot:true,
    careAssistantId: 5,
    clientId: 6
}, ]; 

_data is a global variable inside my script so I'm not sure if this is causing troubles with kendo. The next bit of code is loaded in after my _data variable.

$("#scheduler").kendoScheduler({
    date: new Date(_startDate),    // Change this to current date with twig
    startTime: new Date(_startTime), // Change this to 12:00 AM of current date
    allDaySlot: true,
    edit: function(e) {
        editScheduler(e);
    },
    moveStart: function(e) {
        moveStartScheduler(e);
    },
    navigate: function(e) {
        navigateScheduler(e);
    },
    remove: function(e) {
        removeScheduler(e);
    },
    resize: function(e) {
        resizeScheduler(e);
    },
    resizeEnd: function(e) {
        resizeEndScheduler(e);
    },
    move: function(e) {
        moveScheduler(e);
    },
    moveEnd: function(e) {
        moveEndScheduler(e);
    },
    add: function(e) {
        addScheduler(e);
    },
    dataBound: function(e) {
        dataBoundScheduler(e);
    },
    save: function(e) {
        saveScheduler(e);
    },
    views: [
        "week",
        "month"
    ],
    dataSource: {
        data: _data,
        schema: {
            model: {
                id: "eventID",
                fields: {
                        eventID: { type: "number" },
                        title: { defaultValue: "No title", validation: { required: true } },
                        start: { type: "date" },
                        end: { type: "date" },
                        pending: { type: "boolean", defaultValue:true },
                        recurrenceRule: { nullable: true },
                        recurrenceException: { nullable: true },
                        description: { nullable: true },
                        careAssistantId: { nullable: true },
                        clientId: { nullable:true },
                        ownTimeSlot: { type: "boolean", defaultValue:true },
                        isAllDay: { type: "boolean" }
                }
            }
        }
    },
    group: {
        resources: [ "care" ]
    },
    resources: [
        {
            field: "careAssistantId",
            name: "care",
            dataSource: [
                { 
                    // Change the text with care giver name, change value with care giver id
                    text: _schedulerName, value: _schedulerId, color: "#00FF00" 
                }
            ],
            title: "Care"
        }
    ]
});

All variables that I'm using are defined, so maybe I just have a small syntax error somewhere. Oddly enough, there are no errors being generated in firefox firebug.

4

1 回答 1

2

稍作修改的版本似乎可以按预期工作:http: //jsbin.com/iJATePU/1/edit

这是有效的代码:

var _data = [{
    eventID: 7,
    title: "Physical therapy.",
    start: new Date("2013/06/12 13:00"),
    end: new Date("2013/06/12 14:30"),
    pending:true,
    recurrenceRule: "",
    recurrenceException: "",
    description: "Take my mom to her physical therapy.",
    isAllDay:false,
    ownTimeSlot:true,
    careAssistantId: 5,
    clientId: 6
},{
    eventID: 8,
    title: "Group meeting.",
    start: new Date("2013/06/13 12:00"),
    end: new Date("2013/06/13 13:30"),
    pending:false,
    recurrenceRule: "",
    recurrenceException: "",
    description: "Take my brother to his group meeting.",
    isAllDay:false,
    ownTimeSlot:true,
    careAssistantId: 5,
    clientId: 6
},{
    eventID: 9,
    title: "Make dinner.",
    start: new Date("2013/06/13 18:00"),
    end: new Date("2013/06/13 20:30"),
    pending:true,
    recurrenceRule: "FREQ=DAILY;INTERVAL=2;COUNT=8",
    recurrenceException: "",
    description: "Make dinner for my mom.",
    isAllDay:false,
    ownTimeSlot:true,
    careAssistantId: 5,
    clientId: 6
} ];

$("#scheduler").kendoScheduler({
  date: new Date("2013/06/13"),    // Change this to current date with twig
  startTime: new Date("2013/06/13 10:00"),    // Change this to current date with twig
  allDaySlot: true,
  edit: function(e) {
    editScheduler(e);
  },
  moveStart: function(e) {
    moveStartScheduler(e);
  },
  navigate: function(e) {
    navigateScheduler(e);
  },
  remove: function(e) {
    removeScheduler(e);
  },
  resize: function(e) {
    resizeScheduler(e);
  },
  resizeEnd: function(e) {
    resizeEndScheduler(e);
  },
  move: function(e) {
    moveScheduler(e);
  },
  moveEnd: function(e) {
    moveEndScheduler(e);
  },
  add: function(e) {
    addScheduler(e);
  },
  dataBound: function(e) {
    dataBoundScheduler(e);
  },
  save: function(e) {
    saveScheduler(e);
  },
  views: [
    "week",
    "month"
  ],
  dataSource: {
    data: _data,
    schema: {
      model: {
        id: "eventID",
        fields: {
          eventID: { type: "number" },
          title: { defaultValue: "No title", validation: { required: true } },
          start: { type: "date" },
          end: { type: "date" },
          pending: { type: "boolean", defaultValue:true },
          recurrenceRule: { nullable: true },
          recurrenceException: { nullable: true },
          description: { nullable: true },
          careAssistantId: { nullable: true },
          clientId: { nullable:true },
          ownTimeSlot: { type: "boolean", defaultValue:true },
          isAllDay: { type: "boolean" }
        }
      }
    }
  }
});
于 2013-10-10T06:41:51.500 回答