Instead of destroying the data and refilling it, I ended up modifying jquery.datatables.js version 1.10.2 .
The main problem is that line 1935 in jquery.datatables.js checks if a line has already been created:
if ( aoData.nTr === null ) { _fnCreateTr(oSettings, iDataIndex); }
One way to fix this is to set aoData.nTr = null . But this can disrupt other functions or cause unwanted side effects, so this is not an acceptable solution.
I preferred to add the .draw() function argument instead (line 7137), and adding a parameter called bForceReDraw ( draw() already takes the argument, so we add the second argument):
_api_register('draw()', function (resetPaging, forceReDraw) { return this.iterator( 'table', function ( settings ) { settings.bForceReDraw = forceReDraw === true; _fnReDraw(settings, resetPaging === false); } ); } );
Then I changed the null check on line 1935 to:
if ( aoData.nTr === null || oSettings.bForceReDraw === true ) { _fnCreateTr(oSettings, iDataIndex); }
The _fnCreateTr() function also has a null check on nTr (line 1586), so I also needed to change it:
if ( row.nTr === null || oSettings.bForceReDraw === true ) { nTr = nTrIn || document.createElement('tr'); ...
Now we just call draw() with a new argument, and everything works as expected.
$('#data').DataTable().columns.adjust().draw(false, true);