mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-19 12:52:11 +01:00
Fixed: Now restore the width of the original table on fnDestory. This is needed for when using sScrollXInner, and on other occasions where using DataTables will force the table to be wider than it otherwise would be - 2840
This commit is contained in:
parent
596ea4b9e9
commit
44bf320ac8
13
media/js/jquery.dataTables.js
vendored
13
media/js/jquery.dataTables.js
vendored
@ -1071,6 +1071,13 @@
|
|||||||
*/
|
*/
|
||||||
this.asDestoryStrips = [];
|
this.asDestoryStrips = [];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Variable: sDestroyWidth
|
||||||
|
* Purpose: If restoring a table - we should restore it's width
|
||||||
|
* Scope: jQuery.dataTable.classSettings
|
||||||
|
*/
|
||||||
|
this.sDestroyWidth = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variable: fnRowCallback
|
* Variable: fnRowCallback
|
||||||
* Purpose: Call this function every time a row is inserted (draw)
|
* Purpose: Call this function every time a row is inserted (draw)
|
||||||
@ -2113,6 +2120,9 @@
|
|||||||
nBody.appendChild( oSettings.aoData[i].nTr );
|
nBody.appendChild( oSettings.aoData[i].nTr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Restore the width of the original table */
|
||||||
|
oSettings.nTable.style.width = _fnStringToCss(oSettings.sDestroyWidth);
|
||||||
|
|
||||||
/* If the were originally odd/even type classes - then we add them back here. Note
|
/* If the were originally odd/even type classes - then we add them back here. Note
|
||||||
* this is not fool proof (for example if not all rows as odd/even classes - but
|
* this is not fool proof (for example if not all rows as odd/even classes - but
|
||||||
* it's a good effort without getting carried away
|
* it's a good effort without getting carried away
|
||||||
@ -6315,6 +6325,9 @@
|
|||||||
*/
|
*/
|
||||||
oSettings.oApi = _that.oApi;
|
oSettings.oApi = _that.oApi;
|
||||||
|
|
||||||
|
/* State the table's width for if a destroy is called at a later time */
|
||||||
|
oSettings.sDestroyWidth = $(this).width();
|
||||||
|
|
||||||
/* Store the features that we have available */
|
/* Store the features that we have available */
|
||||||
if ( typeof oInit != 'undefined' && oInit !== null )
|
if ( typeof oInit != 'undefined' && oInit !== null )
|
||||||
{
|
{
|
||||||
|
19
media/unit_testing/tests_onhold/1_dom/2840-restore-table-width.js
Executable file
19
media/unit_testing/tests_onhold/1_dom/2840-restore-table-width.js
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
// DATA_TEMPLATE: dom_data
|
||||||
|
oTest.fnStart( "2840 - Restore table width on fnDestory" );
|
||||||
|
|
||||||
|
$(document).ready( function () {
|
||||||
|
document.cookie = "";
|
||||||
|
$('#example').dataTable( {
|
||||||
|
"sScrollX": "100%",
|
||||||
|
"sScrollXInner": "110%"
|
||||||
|
} );
|
||||||
|
$('#example').dataTable().fnDestroy();
|
||||||
|
|
||||||
|
oTest.fnTest(
|
||||||
|
"Width after destroy",
|
||||||
|
null,
|
||||||
|
function () { return $('#example').width() == "800"; }
|
||||||
|
);
|
||||||
|
|
||||||
|
oTest.fnComplete();
|
||||||
|
} );
|
Loading…
x
Reference in New Issue
Block a user