How to add another header row when the datatable is created dynamically

How to add another header row when the datatable is created dynamically

RSiebelingRSiebeling Posts: 10Questions: 0Answers: 0
edited February 2014 in General
Hi,

my datatable is created dynamically, I've created an example on http://live.datatables.net/lor/6/edit?html,js,output

This will create a table with one header row and two data rows.
What is the best way to add another header row?

I'm trying to add it using jQuery using the following code:

var firstHeaderRow = dataTable.table().header();
var header = $(dataTable.table().header());

var secondHeaderRow = firstHeaderRow;
$(firstHeaderRow.rows[0]).after($(secondHeaderRow).html());

But this is not working correctly and I don't think this is the right way to do it? Or is it?

Please help,
kind regards,

Richard

Replies

  • RSiebelingRSiebeling Posts: 10Questions: 0Answers: 0
    edited February 2014
    Sorry, should have include a link to a working example, I've added it
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Its far from perfect, but this might help: http://live.datatables.net/lor/7/edit . The header() function gives you the thead element, not the row.

    Allan
  • RSiebelingRSiebeling Posts: 10Questions: 0Answers: 0
    Allan, thanks for the answer, is this the best path to choose to add dynamically multiple header rows or is there an alternative way to maybe do it in a better way?
This discussion has been closed.