我尝试在PHP中切换Kendo UI Gantt示例的数据源。我已经将模式与返回的内容进行了映射,但我只得到了一个标题为"未定义"的空白甘特图。
{
"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"
}
}
上面是发送回Kendo的JSON,但它没有呈现。
找到解决方案:
我输入了整数,将父项设置为null而不是零(0),并在PHP层中将日期转换为毫秒,然后输入到Kendo。我还删除了导致创建以下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
}]