Skip to content

Commit aca54b9

Browse files
committed
Fix: Improved DOM ordering for scrolling tables - colgroup, thead, tfoot
- Fixes DataTables/FixedColumns #8
1 parent e06a6a4 commit aca54b9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

js/core/core.scrolling.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,18 @@ function _fnScrollDraw ( settings )
227227
// Remove the old minimised thead and tfoot elements in the inner table
228228
table.children('thead, tfoot').remove();
229229

230-
// Clone the current header and footer elements and then place it into the inner table
231-
headerCopy = header.clone().prependTo( table );
232-
headerTrgEls = header.find('tr'); // original header is in its own table
233-
headerSrcEls = headerCopy.find('tr');
234-
headerCopy.find('th, td').removeAttr('tabindex');
235-
236230
if ( footer ) {
237231
footerCopy = footer.clone().prependTo( table );
238232
footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
239233
footerSrcEls = footerCopy.find('tr');
240234
}
241235

236+
// Clone the current header and footer elements and then place it into the inner table
237+
headerCopy = header.clone().prependTo( table );
238+
headerTrgEls = header.find('tr'); // original header is in its own table
239+
headerSrcEls = headerCopy.find('tr');
240+
headerCopy.find('th, td').removeAttr('tabindex');
241+
242242

243243
/*
244244
* 2. Take live measurements from the DOM - do not alter the DOM itself!
@@ -418,6 +418,9 @@ function _fnScrollDraw ( settings )
418418
divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
419419
}
420420

421+
// Correct DOM ordering for colgroup - comes before the thead
422+
table.children('colgroup').insertBefore( table.children('thead') );
423+
421424
/* Adjust the position of the header in case we loose the y-scrollbar */
422425
divBody.scroll();
423426

0 commit comments

Comments
 (0)