【问题标题】:Kendo Scheduler not showing data剑道调度程序不显示数据
【发布时间】:2013-10-09 19:28:36
【问题描述】:

我可能只是遗漏了一些东西,但我正在尝试使用提供的数据对象填充 kendo 调度程序。首先加载我的数据对象,然后加载并初始化 kendo 调度程序。请注意,除了加载初始数据集外,其他一切都在调度程序上运行。下面是我的数据:

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 是我脚本中的一个全局变量,所以我不确定这是否会导致剑道出现问题。下一段代码是在我的 _data 变量之后加载的。

$("#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"
        }
    ]
});

我使用的所有变量都已定义,所以也许我只是在某个地方出现了一个小的语法错误。奇怪的是,firefox firebug 中没有生成错误。

【问题讨论】:

  • 我遇到了同样的问题,即未在调度程序中显示数据。你有没有解决过这个问题?
  • 我做了,我只是下载了他们在示例中使用的脚本,而不是官方分发的脚本。示例脚本是不同的并且是最新的。

标签: javascript jquery kendo-ui kendo-scheduler


【解决方案1】:

稍作修改的版本似乎可以按预期工作: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" }
        }
      }
    }
  }
});

【讨论】:

  • 谢谢,不幸的是我需要实现分组,因为我限制了一个组的可用时间段。但我想我看到了一个你修复的语法错误,它可以让我的东西正常工作。如果那个语法错误是什么造成的,我会接受你的回答。
  • @AtanasKorchev 如何在剑道调度程序中以 15 分钟间隔定义时间间隔?像 1.15, 1.30, 1.45, 2.00, 2.15 这样的....我试过 Minutes Per Row 但它不起作用。我无法为此找到最新的文档网。请帮助...
猜你喜欢
  • 1970-01-01
  • 2013-07-30
  • 1970-01-01
  • 1970-01-01
  • 2013-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多