Formatting table-header with json-data

Formatting table-header with json-data

mbaasmbaas Posts: 67Questions: 24Answers: 1
edited March 2014 in DataTables 1.9
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

Replies

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    HI Michael,

    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
  • mbaasmbaas Posts: 67Questions: 24Answers: 1
    Ok, excellent, thanks :)
This discussion has been closed.