Kendo UI Gantt图表不处理JSON

时间:2016-05-13 10:26:42

标签: php json kendo-ui kendo-gantt

我试图在PHP中切换Kendo UI Gantt示例的数据源。我已经将模式与返回的内容进行了映射,但我只得到一个带有一个标题的空白甘特图 - " undefined"。

{
  "1": {
    "id": "1",
    "orderId": "1",
    "title": "TESTER1",
    "start": "\/new Date('2016-01-01 09:00:00')\/",
    "end": "\/new Date('2016-02-01 00:00:00')\/",
    "project": "1",
    "client": "4218",
    "parent": "0",
    "percentComplete": "10.11"
  },
  "2": {
    "id": "2",
    "orderId": "2",
    "title": "TESTER2",
    "start": "\/new Date('2016-01-03 09:00:00')\/",
    "end": "\/new Date('2016-02-01 00:00:00')\/",
    "project": "1",
    "client": "4218",
    "parent": "0",
    "percentComplete": "50.00"
  }
}

上面是JSON被发送回剑道,但它没有渲染。

1 个答案:

答案 0 :(得分:0)

找到解决方案:

在输入Kendo之前,我键入了整数,将父设置为null而不是零(0)并将PHP中的日期转换为毫秒。我还删除了导致创建下面JSON的键。这解决了我的渲染问题。

    [{
    "id": 1,
    "orderId": 1,
    "title": "TESTER1",
    "start": "\/Date(1463126400000)\/",
    "end": "\/Date(1463958000000)\/",
    "project": 1,
    "client": 4218,
    "parent": null,
    "percentComplete": 10
}, {
    "id": 2,
    "orderId": 2,
    "title": "TESTER2",
    "start": "\/Date(1463990400000)\/",
    "end": "\/Date(1464130800000)\/",
    "project": 1,
    "client": 4218,
    "parent": null,
    "percentComplete": 50
}]