Configure column rendering using HTML5 data-*
Configure column rendering using HTML5 data-*
sliekens
Posts: 97Questions: 17Answers: 2
Can I configure a column renderer function by setting a data-*
attribute on a <th>
or <td>
tag? If so, how? Otherwise, why not?
Related links
https://datatables.net/examples/advanced_init/column_render.html
https://datatables.net/examples/advanced_init/object_dom_read.html
https://datatables.net/examples/advanced_init/html5-data-options.html
https://datatables.net/examples/advanced_init/html5-data-attributes.html
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
No. You cannot define a Javascript function via an HTML 5 data-8 attribute. That is a limitation of using that method and I'm not aware of any way around it. To define a Javascript function you need to use Javascript.
Allan
Okay so I'm now in a situation where I'm already using
data-*
attributes to configure my columns and I just found out that I can't configure a renderer in this way.Should I start removing the attributes from the HTML and configure columns using the options object or is it safe to combine both?
You can combine them: http://live.datatables.net/gilasajo/1/edit - page length and scrolling being set.
Allan