Newcoma
Newcoma

Reputation: 809

fndraw on datatables not working

I'm using the datatables plugin and want to reload the sorting of the table columns by the click of a button. I'm changing the content of the table clientside. But nothing happens when I click redrawBtn. Everything else is working properly.

// datatable config
var oTable = tablesorterEl.dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"bRetrieve": false,
"asSorting": true,
"bServerSide": false,
"bSearchable": true,
"aaSorting": [],                    
"oLanguage": {
"sSearch": ""
},
"bStateSave": true
});

// redraw button
$('.redrawBtn').click(function(){

  oTable.fnDraw();
});

Upvotes: 0

Views: 5850

Answers (2)

Newcoma
Newcoma

Reputation: 809

I found out I have to manipulate the dom using a dataTables function. Like

$('.redrawBtn').click(function(){
   oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell. Will redraw by default
});

Upvotes: 1

pietro909
pietro909

Reputation: 1861

if you want fnDraw to re-sort dataTable you should write oTable.fnDraw(true).

pietro

Upvotes: 2

Related Questions