what is columns.title similar initialization option for footer

what is columns.title similar initialization option for footer

JunwJunw Posts: 4Questions: 2Answers: 0
edited October 2016 in Free community support

based on this
title
Setting a text to the 'title' attribute in the column option will change the header TH of the table.

Is there a option to set the footer?
In my datatable, the header column title is change but not the footer and it became inconsistent

sample:
https://jsfiddle.net/r8vz7pak/

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Answer ✓

    Sorry there currently isn't one. The only way to have a footer element created is to have it in the DOM when the DataTable is initialised.

    This is something that does come up fairly regularly, so it is something I will look into in future.

    Allan

  • JunwJunw Posts: 4Questions: 2Answers: 0

    ok, thanks,
    i'll just modify the footer element after datatable initialized

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    I'd recommend doing it before the table is initialised if you can. Otherwise DataTables won't know that there is a footer and any changes in column visibility, etc, wouldn't be reflected in the footer.

    Allan

  • DataTablesVerbundDataTablesVerbund Posts: 3Questions: 0Answers: 0

    @allen As this comes up quite regularly here, is there some kind of goto-solution or best practice example that one could easily c&p?

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    edited April 2017
    $('#myTable').append(
      '<tfoot>'+
        '<tr>'+
           '<th>...</th>'+
           '<th>...</th>'+
           '<th>...</th>'+
           ...
        '<tr>'+
      '</tfoot>'
    );
    
    $('#myTable').DataTable();
    

    Allan

This discussion has been closed.