Reputation: 5591
I'm attempting to write data using dyntable to an html table. One of the headers is called Week of year
. In the JSON file, the name is also Week of year
(with the spaces). When passing the json to 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}]
}});
and drawing to an html table:
<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>
The table draws fine for a
to f
, but appears as undefined for both weekOfYear
and Week of year
. How do you pass json to dynatable that contains spaces?
Upvotes: 1
Views: 616
Reputation: 94
That's very odd. It didn't seem to work for me at first either, but here's a link to a working example with your data. Hopefully this helps
I changed
<th>weekOfYear</th>
to
<th>week</th>
Upvotes: 1