1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-18 11:52:11 +01:00

Fixed: fnDestroy didn't restore columns which had been hidden by DataTables, resulting in these columns being completely lost - 2569

This commit is contained in:
Allan Jardine 2010-08-22 08:47:06 +01:00
parent 505bfce7c2
commit 29d7a0a182
4 changed files with 31 additions and 1 deletions

View File

@ -18,6 +18,7 @@
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] }, { "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
{ "bVisible": false, "aTargets": [ 3 ] } { "bVisible": false, "aTargets": [ 3 ] }
] } ); ] } );
$('#example').dataTable().fnDestroy();
} ); } );
</script> </script>
</head> </head>

View File

@ -28,7 +28,7 @@
<h1>Live example</h1> <h1>Live example</h1>
<div id="demo"> <div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" style="width:80%"> <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead> <thead>
<tr> <tr>
<th>Rendering engine</th> <th>Rendering engine</th>

View File

@ -2040,6 +2040,15 @@
var nBody = oSettings.nTBody; var nBody = oSettings.nTBody;
var i, iLen; var i, iLen;
/* Restore hidden columns */
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
{
if ( oSettings.aoColumns[i].bVisible === false )
{
this.fnSetColumnVis( i, true );
}
}
/* Remove the DataTables generated nodes, events and classes */ /* Remove the DataTables generated nodes, events and classes */
oSettings.nTable.parentNode.removeChild( oSettings.nTable ); oSettings.nTable.parentNode.removeChild( oSettings.nTable );
$(oSettings.nTableWrapper).remove(); $(oSettings.nTableWrapper).remove();

View File

@ -0,0 +1,20 @@
// DATA_TEMPLATE: dom_data
oTest.fnStart( "Destroy with hidden columns" );
$(document).ready( function () {
$('#example').dataTable( {
"aoColumnDefs": [
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
{ "bVisible": false, "aTargets": [ 3 ] }
]
} );
$('#example').dataTable().fnDestroy();
oTest.fnTest(
"Check that the number of columns in table is correct",
null,
function () { return $('#example tbody tr:eq(0) td').length == 5; }
);
oTest.fnComplete();
} );