From c20681668a415e37696777d872bcf030d96d3053 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 10 Dec 2013 17:54:53 +0000 Subject: [PATCH] New: no-footer class automatically added to the table when no tfoot - It appears that ti is impossible to know in CSS if a table doesn't have a tfoot element reliably and cross browser, so I've added a class which is added to the table automatically if the table has no footer or the fotoer is empty to complete the styling of the table. - Fixed error when there are no cells in an empty TR row in the footer. --- .datatables-commit-sync | 2 +- media/css/jquery.dataTables.css | 4 ++++ media/js/jquery.dataTables.js | 18 +++++++++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index a3f74ab5..6274ef69 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -a5ec3278bb4c799d750ce6301268be88a300e9b9 +d2937aa4bf198fc04533c0ed9e48dabeed4b967f diff --git a/media/css/jquery.dataTables.css b/media/css/jquery.dataTables.css index 9c710eda..b7806f1b 100644 --- a/media/css/jquery.dataTables.css +++ b/media/css/jquery.dataTables.css @@ -210,6 +210,10 @@ table.dataTable.order-column.hover tbody tr.odd:hover.selected > .sorting_3, table.dataTable.order-column.hover tbody tr.even:hover.selected > .sorting_3 { background-color: #a4b2cb; } +table.dataTable.no-footer { + border-bottom: 1px solid #111111; + margin-bottom: 0.5em; +} table.dataTable, table.dataTable th, diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index e0017ace..3f9d6861 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -1602,7 +1602,7 @@ if ( tfoot !== null ) { var cells = oSettings.aoFooter[0]; - for ( i=0, ien=columns.length ; i').appendTo(this); } oSettings.nTHead = thead[0]; var tbody = $(this).children('tbody'); if ( tbody.length === 0 ) { - tbody = [ document.createElement( 'tbody' ) ]; - this.appendChild( tbody[0] ); + tbody = $('').appendTo(this); } oSettings.nTBody = tbody[0]; @@ -6165,12 +6163,13 @@ { // If we are a scrolling table, and no footer has been given, then we need to create // a tfoot element for the caption element to be appended to - tfoot = [ document.createElement( 'tfoot' ) ]; - this.appendChild( tfoot[0] ); + tfoot = $('').appendTo(this); } - if ( tfoot.length > 0 ) - { + if ( tfoot.length === 0 || tfoot.children().length === 0 ) { + $(this).addClass( oSettings.oClasses.sNoFooter ); + } + else if ( tfoot.length > 0 ) { oSettings.nTFoot = tfoot[0]; _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot ); } @@ -13281,6 +13280,7 @@ $.extend( DataTable.ext.classes, { "sTable": "dataTable", + "sNoFooter": "no-footer", /* Paging buttons */ "sPageButton": "paginate_button",