Does Datatables always require a pre-existing HTML table to exist first?

Does Datatables always require a pre-existing HTML table to exist first?

BasementjackBasementjack Posts: 19Questions: 7Answers: 0

Hi, just starting with Datatables,

All the examples I see look like they start out with an HTML table before DT gets to work.
If I'm using an ajax data source, is it possible to skip that and just include an empty

<table ID="mytable"></table>

Or do the tables always need to be complete with the columns that we expect from Datatables?

  • Jack

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    If I'm using an ajax data source, is it possible to skip that and just include an empty [table]

    Yes you can just use an empty table tag. Use the columns.title option to set the column header title when DataTables constructed your columns.

    DataTables will automatically generate the thead and tbody elements as required.

    Allan

  • BasementjackBasementjack Posts: 19Questions: 7Answers: 0

    Thanks Allan!

This discussion has been closed.