Datatable destroy erroring with fixedheader

Datatable destroy erroring with fixedheader

wsharpwsharp Posts: 1Questions: 1Answers: 0

I am receiving Uncaught TypeError: Cannot read property 'namespace' of undefined when calling the destroy() of a datatable. I have tracked it down to possibly being this line of code in dataTables.fixedHeader.js. In the callback in the _constructor function:

        dt.on( 'destroy.dtfc', function () {
            dt.off( '.dtfc' );
            $(window).off( this.s.namespace );
        } );

If I change the

$(window).off( this.s.namespace );   

to be

$(window).off( that.s.namespace ); 

note: (changed 'this' to 'that') everything works as it should.

Not sure if I am initializing things incorrectly however it seems pretty basic on what I am doing.

I initialize my table and data as follows:

var table = $('#SearchResultsGrid').DataTable({
                        data: result,
                        responsive: true
});
new $.fn.dataTable.FixedHeader(table);

Then when I perform an ajax call I destroy the table and then reinitialize (needed due to column changes etc).

$('#SearchResultsGrid').DataTable().destroy();   // this is the line that is throwing the errror.

Anyone else seeing this behavior when trying to destroy() and having implemented fixed headers?

Thanks,
Wade Sharp

This discussion has been closed.