Datatables why is thead needed

Datatables why is thead needed

PaulFreeWebsPaulFreeWebs Posts: 63Questions: 4Answers: 1
edited February 2017 in Free community support

I have fully customized my table but without <thead> but now the datatables functions wont work :(, if i add the <thead> back it messes up my design but allows the functions to work, why is this?

This question has accepted answers - jump to:

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    DataTables requires a valid HTML table, which means including a thead tag.

  • PaulFreeWebsPaulFreeWebs Posts: 63Questions: 4Answers: 1

    ok, is there a way I can use thead without it messing up my table? if you want an example i can give you one

  • PaulFreeWebsPaulFreeWebs Posts: 63Questions: 4Answers: 1

    here is an example https://jsfiddle.net/p2noyha4/ this is what its meant to look like http://prntscr.com/e4jf9y

  • allanallan Posts: 63,850Questions: 1Answers: 10,519 Site admin
    Answer ✓

    ok, is there a way I can use thead without it messing up my table?

    No. As the manual states the thead is required.

    Having said that, if it is only the visual aspect you are concerned about, just make it display: none.

    Allan

  • PaulFreeWebsPaulFreeWebs Posts: 63Questions: 4Answers: 1
    edited February 2017

    in css so it be like #tableid thead {
    display: none
    }
    ?

    EDIT: done wat u said now i dont see the coloumn names https://jsfiddle.net/p2noyha4/3/

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited February 2017 Answer ✓

    You don't want "display: none".
    First you need to fix your HTML: thead td should be thead tr td, probably with the use of colspan. Then you need to apply css styling to your heading as required.

  • PaulFreeWebsPaulFreeWebs Posts: 63Questions: 4Answers: 1
    edited February 2017

    ok fixed the html if i have followed what u said correctly.
    https://jsfiddle.net/p2noyha4/5/ with the css, would i just add that on to .table.dataTable thead
    ?

    since i have css that does most of the table and it might not work correctly if i add abit to that

    EDIT: here look at this too https://jsfiddle.net/p2noyha4/6/ its messed up near search, and not connected to the other part

  • PaulFreeWebsPaulFreeWebs Posts: 63Questions: 4Answers: 1

    Fixed this now, thanks for the help!

This discussion has been closed.