When using Buttons API and I reload a new dataTable error with button index for colvis

When using Buttons API and I reload a new dataTable error with button index for colvis

samanthadenellesamanthadenelle Posts: 1Questions: 1Answers: 0

Issue only occurs if i use the button to hide a column. I can switch tables and the destroy and rebuild table works fine. However if I select a column to hide it seems to lose the reference to the buttons index.

Example
Table has columns 1, 2, 3, 4
I create DataTable as below

window.Globaltable = $('#search_result').DataTable({
dom: 'Bfrtip',
buttons: [
'colvis'
],
"lengthMenu": [[10, 25, 50, 100, 250, 500, 1000, -1], [10, 25, 50, 100, 250, 500, 1000, "All"]]
});

I can load the table and see the data all working. However if i use the column visibility button and select 3 (column) to hide, and then call
var table = $('#search_result').DataTable();
table.destroy();
it breaks on

_indexToButton: function ( idx )
{
if ( typeof idx === 'number' || idx.indexOf('-') === -1 ) {
return this.s.buttons[ idx*1 ];
}

    var idxs = idx.split('-');
    return this.s.subButtons[ idxs[0]*1 ][ idxs[1]*1 ];
},

cause it cannot reference the index to the button. Is this a bug?

This discussion has been closed.