Multiple FixedHeaders on the same page
Multiple FixedHeaders on the same page
RdeBoer
Posts: 10Questions: 0Answers: 0
Hello,
Thanks for this great package.
I was wondering whether there's a way to use FixedHeader on pages that contain multiple tables, so that the call $("table").dataTable() returns multiple objects?
I was hoping that something like this would work, but it doesn't:
[code]
var tables= $("table").dataTable();
new FixedHeader(tables);
[/code]
or in fact
[code]
var tables = $("table").dataTable();
for (var t in tables) {
new FixedHeader(tables[t]);
}
[/code]
What does work is;
[code]
var table1 = $("#id1").dataTable();
new FixedHeader(table1);
var table2 = $("#id2").dataTable();
new FixedHeader(table2);
[/code]
However the above is not a good solution for me as I'm using DataTables in a Drupal context where the tables on the page do not have id's or unique CSS classes, or the id's aren't known to my code.
Any suggestions?
Thanks for this great package.
I was wondering whether there's a way to use FixedHeader on pages that contain multiple tables, so that the call $("table").dataTable() returns multiple objects?
I was hoping that something like this would work, but it doesn't:
[code]
var tables= $("table").dataTable();
new FixedHeader(tables);
[/code]
or in fact
[code]
var tables = $("table").dataTable();
for (var t in tables) {
new FixedHeader(tables[t]);
}
[/code]
What does work is;
[code]
var table1 = $("#id1").dataTable();
new FixedHeader(table1);
var table2 = $("#id2").dataTable();
new FixedHeader(table2);
[/code]
However the above is not a good solution for me as I'm using DataTables in a Drupal context where the tables on the page do not have id's or unique CSS classes, or the id's aren't known to my code.
Any suggestions?
This discussion has been closed.
Replies
[code]
var tables = $("table").dataTable();
for (var t = 0; t < tables.length; t++) {
new FixedHeader(tables[t]);
}
[/code]
[code]
var tables = $("table").dataTable();
for (var t = 0; t < tables.length; t++) {
new FixedColumns(tables[t], { iLeftColumns: 1 });
}
[/code]
Suggestions?
[code]
$("table.dataTable").dataTable().each( function () {
new FixedHeader( this );
}
[/code]
(I've added a class as well so it only picked up DataTables tables).
FixedColumns however takes a DataTables object in its constructor (not sure why I did that - bit stupid on reflection...):
[code]
$("table.dataTable").dataTable().each( function () {
new FixedHeader( $(this).dataTable() );
}
[/code]
I'm going to spend a bit of time sorting out the plug-ins and make them all 1. sensible, and 2. confirmative, once 1.10 is in beta / released...
Allan