Formatting table-header with json-data
Formatting table-header with json-data
mbaas
Posts: 67Questions: 24Answers: 1
Hi,
I'm working on a table that is created by DT based on JSON-data. In my old HTML-Version I had applied some CSS to the header-cells - how can I inject that formatting now when DT prepares the table for me?
Tx
Michael
I'm working on a table that is created by DT based on JSON-data. In my old HTML-Version I had applied some CSS to the header-cells - how can I inject that formatting now when DT prepares the table for me?
Tx
Michael
This discussion has been closed.
Replies
You would uses a standard jQuery `addClass()` once the table has been constructed:
[code]
$('#myTable').dataTable( ... );
$('#myTable thead th:eq(2)').addClass( 'number-formatting' );
[/code]
For example.
DataTables options for creating a header are intentionally limited to just the content of the cell through the sTitle option. Providing a more complete solution would be a slippery slope I think, and it would end up just being best to use jQuery to construct a header that is any more complex than the simplest case, so you can have complete control over it.
Regards,
Allan