mirror of
https://github.com/DataTables/DataTables.git
synced 2025-03-15 16:29:16 +01:00
Fixed: Destroying a scrolling table was not correctly reassembling the table from it's component parts which are split up for scrolling.
This commit is contained in:
parent
2c4def9353
commit
332d511649
57
media/js/jquery.dataTables.js
vendored
57
media/js/jquery.dataTables.js
vendored
@ -2060,6 +2060,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* When scrolling we had to break the table up - restore it */
|
||||
if ( oSettings.nTable != oSettings.nTHead.parentNode )
|
||||
{
|
||||
$('>thead', oSettings.nTable).remove();
|
||||
oSettings.nTable.appendChild( oSettings.nTHead );
|
||||
}
|
||||
|
||||
if ( oSettings.nTFoot && oSettings.nTable != oSettings.nTFoot.parentNode )
|
||||
{
|
||||
$('>tfoot', oSettings.nTable).remove();
|
||||
oSettings.nTable.appendChild( oSettings.nTFoot );
|
||||
}
|
||||
|
||||
/* Remove the DataTables generated nodes, events and classes */
|
||||
oSettings.nTable.parentNode.removeChild( oSettings.nTable );
|
||||
$(oSettings.nTableWrapper).remove();
|
||||
@ -2204,7 +2217,7 @@
|
||||
/* Draw the headers for the table */
|
||||
_fnDrawHead( oSettings );
|
||||
|
||||
/* Calculate sizes for columns xxx */
|
||||
/* Calculate sizes for columns */
|
||||
if ( oSettings.oFeatures.bAutoWidth )
|
||||
{
|
||||
_fnCalculateColumnWidths( oSettings );
|
||||
@ -3020,36 +3033,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform certain DOM operations after the table has been drawn for the first time */
|
||||
if ( typeof oSettings._bInitComplete == "undefined" )
|
||||
{
|
||||
oSettings._bInitComplete = true;
|
||||
|
||||
/* It is possible that some of the DOM created (particularly if custom) has padding etc
|
||||
* on it which means that the table size is more constrained that when we originally
|
||||
* measured it. As such we check here if this is the case, and correct if needed
|
||||
*/
|
||||
if ( oSettings.nTableWrapper != oSettings.nTable.parentNode &&
|
||||
$(oSettings.nTableWrapper).width() > $(oSettings.nTable.parentNode).width() )
|
||||
{
|
||||
_fnAjustColumnSizing( oSettings );
|
||||
}
|
||||
|
||||
if ( typeof oSettings.fnInitComplete == 'function' &&
|
||||
(oSettings.oFeatures.bServerSide || oSettings.sAjaxSource === null) )
|
||||
{
|
||||
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings );
|
||||
}
|
||||
|
||||
/* Set an absolute width for the table such that pagination doesn't
|
||||
* cause the table to resize - disabled for now.
|
||||
*/
|
||||
//if ( oSettings.oFeatures.bAutoWidth && oSettings.nTable.offsetWidth !== 0 )
|
||||
//{
|
||||
// //oSettings.nTable.style.width = oSettings.nTable.offsetWidth+"px";
|
||||
//}
|
||||
}
|
||||
|
||||
/* Call all required callback functions for the end of a draw */
|
||||
for ( i=0, iLen=oSettings.aoDrawCallback.length ; i<iLen ; i++ )
|
||||
{
|
||||
@ -3060,6 +3043,18 @@
|
||||
oSettings.bSorted = false;
|
||||
oSettings.bFiltered = false;
|
||||
oSettings.bDrawing = false;
|
||||
|
||||
/* On first draw, initilaisation is now complete */
|
||||
if ( typeof oSettings._bInitComplete == "undefined" )
|
||||
{
|
||||
oSettings._bInitComplete = true;
|
||||
|
||||
if ( typeof oSettings.fnInitComplete == 'function' &&
|
||||
(oSettings.oFeatures.bServerSide || oSettings.sAjaxSource === null) )
|
||||
{
|
||||
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -16,5 +16,21 @@ $(document).ready( function () {
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 5; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnTest(
|
||||
"And with scrolling",
|
||||
function () {
|
||||
$('#example').dataTable( {
|
||||
"sScrollY": 200,
|
||||
"aoColumnDefs": [
|
||||
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
|
||||
{ "bVisible": false, "aTargets": [ 3 ] }
|
||||
]
|
||||
} );
|
||||
$('#example').dataTable().fnDestroy();
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 5; }
|
||||
);
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
47
media/unit_testing/tests_onhold/4_server-side/2569.js
Executable file
47
media/unit_testing/tests_onhold/4_server-side/2569.js
Executable file
@ -0,0 +1,47 @@
|
||||
// DATA_TEMPLATE: empty_table
|
||||
oTest.fnStart( "Destroy with hidden columns" );
|
||||
|
||||
$(document).ready( function () {
|
||||
var mTest;
|
||||
|
||||
|
||||
$('#example').dataTable( {
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": "../../../examples/examples_support/server_processing.php",
|
||||
"aoColumnDefs": [
|
||||
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
|
||||
{ "bVisible": false, "aTargets": [ 3 ] }
|
||||
],
|
||||
"fnInitComplete": function () {
|
||||
this.fnDestroy();
|
||||
}
|
||||
} );
|
||||
|
||||
oTest.fnWaitTest(
|
||||
"Check that the number of columns in table is correct",
|
||||
null,
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 5; }
|
||||
);
|
||||
|
||||
|
||||
oTest.fnTest(
|
||||
"And with scrolling",
|
||||
function () {
|
||||
$('#example').dataTable( {
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": "../../../examples/examples_support/server_processing.php",
|
||||
"sScrollY": 200,
|
||||
"aoColumnDefs": [
|
||||
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
|
||||
{ "bVisible": false, "aTargets": [ 3 ] }
|
||||
],
|
||||
"fnInitComplete": function () {
|
||||
this.fnDestroy();
|
||||
}
|
||||
} );
|
||||
},
|
||||
function () { return $('#example tbody tr:eq(0) td').length == 5; }
|
||||
);
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
Loading…
x
Reference in New Issue
Block a user