我试图使用dyntable将数据写入html表。其中一个标题称为Week of year
。在JSON文件中,名称也是Week of year
(带空格)。将json传递给dynatable:
$('#week_table').dynatable({
dataset: {
records: [{"Week of year":"June 9, 2014 to June 15, 2014","a":0.0,"b":0.0,"c":0.0,"d":0.0,"e":1.0,"f":0.0},{"Week of year":"June 16, 2014 to June 22, 2014","a":0.0,"b":0.0,"c":5.0,"d":0.0,"e":16.0,"f":0.0}]
}});
并绘制到html表:
<table id="week_table">
<thead>
<th>weekOfYear</th>
<th>Week of year</th>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
<th>f</th>
</thead>
<tbody>
</tbody>
</table>
该表适用于a
到f
,但对于weekOfYear
和Week of year
都显示为未定义。如何将json传递给包含空格的dynatable?
答案 0 :(得分:1)
这很奇怪。起初它似乎也不适合我,但这里有一个链接到你的数据的工作示例。希望这有助于
我改变了
<th>weekOfYear</th>
到
<th>week</th>