DataTables with jquery-ui tabs and FixedHeader
DataTables with jquery-ui tabs and FixedHeader
zuckerj
Posts: 17Questions: 0Answers: 0
I'm attempting to implement a page using DataTables with FixedHeaders and jquery-ui (tabs)
The page has three tabs, each tab contains multiple tables.
I have successfully got all the tables to render properly across all the tabs... when I do not attempt to use FixedHeaders. When I enable FixedHeaders the javascript breaks. The error I'm getting is referencing the FixedHerader.js script:
Uncaught TypeError: Cannot read property 'oScroll' of null
I have successfully implemented FixedHeader on another non-tab page, with DataTables.
Any suggestions or help VERY appreciated.
Here's a snippet of code for one of the tables:
[code]
$(document).ready(function() {
$('#detail_Assessment').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aLengthMenu": [[10,25,50,100,-1], [10,25,50,100,"All"]],
"iDisplayLength": -1
,"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if( aData[1] == '0' )
{
$('td:eq(1)', nRow).html( 'Incorrect' );
}
if( aData[1] == '1' )
{
$('td:eq(1)', nRow).html( 'Correct' );
}
return nRow;
}
,"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
/* Avg Accuracy Total */
var iTotalAccuracy = 0;
var iTotalAccuracyInvalid = 0;
for ( var i=0 ; i
The page has three tabs, each tab contains multiple tables.
I have successfully got all the tables to render properly across all the tabs... when I do not attempt to use FixedHeaders. When I enable FixedHeaders the javascript breaks. The error I'm getting is referencing the FixedHerader.js script:
Uncaught TypeError: Cannot read property 'oScroll' of null
I have successfully implemented FixedHeader on another non-tab page, with DataTables.
Any suggestions or help VERY appreciated.
Here's a snippet of code for one of the tables:
[code]
$(document).ready(function() {
$('#detail_Assessment').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aLengthMenu": [[10,25,50,100,-1], [10,25,50,100,"All"]],
"iDisplayLength": -1
,"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if( aData[1] == '0' )
{
$('td:eq(1)', nRow).html( 'Incorrect' );
}
if( aData[1] == '1' )
{
$('td:eq(1)', nRow).html( 'Correct' );
}
return nRow;
}
,"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
/* Avg Accuracy Total */
var iTotalAccuracy = 0;
var iTotalAccuracyInvalid = 0;
for ( var i=0 ; i
This discussion has been closed.
Replies
My issue isn't necessarily getting FixedHeader to function with tabs. After more testing I'm now struggling getting FixedHeader to function with multiple tables. This seems to break JS.
I'm using PHP to build the page, and dynamically generate the JS.
I'm looping through a table definition array to generate the DataTables code for each table. The code for each table looks a bit like this now:
[code]
$(document).ready(function() {
$('#detail_Assessment').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aLengthMenu": [[10,25,50,100,-1], [10,25,50,100,"All"]],
"iDisplayLength": -1
,"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if( aData[1] == '0' )
{
$('td:eq(1)', nRow).html( 'Incorrect' );
}
if( aData[1] == '1' )
{
$('td:eq(1)', nRow).html( 'Correct' );
}
return nRow;
}
,"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
/* Avg Accuracy Total */
var iTotalAccuracy = 0;
var iTotalAccuracyInvalid = 0;
for ( var i=0 ; i
i was using bootstrap tabs and it was all messed up and then switched to jqueryui tabs and that didnt provide any answers so i switched back to bootstrap tabs.
long story short i fixed the issue by editing the way the css controls the display in tabs.
giving the undisplayed content instead of a display:none; a position absolute and a left -500000px; and then heading to the displayed class and hitting it with relative and the left 0 fixed the issue, the problem i run into now with this is that when you have a different browser width due to a length change in the page the headers dont reload and are offset the width of the scrollbar etc. because the div reloads after the header realigns itself. minus this subtle bug that fixes itself after a scroll seems to work great! hope this helps.
I took it a little farther and was able to get a marginally cleaner version by giving the wrapper of the content a position relative so i can align all absolute elements inside to it, static positioning was causing some issues to say the least had forgotten all about the parent if your still having issues good luck hope it works out for you.
I'll look at what you have described in more detail when I have more time. For the time being I have just axed this "Fixed Header" functionality from my application specification, for TAB contained data.
Thanks again, and I'll let you know if I get it worked out.