Specify Column Data via HTML data attributes?
Specify Column Data via HTML data attributes?

In my initiailzation I have columns defined to match my AJAX JSON data as follows (example):
columns: [
{ data: "column1" },
{ data: "column2" },
{ data: "column3" }
]
Is there a way to avoid this and define this from the view via html data attributes like this?:
<table id="my_datatable" data-source="my_data.json">
<thead>
<tr>
<th data-column="column1">Column 1</th>
<th data-column="column2">Column 2</th>
<th data-column="column3">Column 3</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The option you are looking for is
columns.data
so it would bedata-data="column1"
. For example:http://live.datatables.net/fufudeve/1/edit
Kevin
Perfect - thanks.