Programmatically Change the DisplayLength of DataTables

Viewed 1987

I have been using dataTables for a while and its a solid tool. There is a option for setting the initial display length, iDisplayLength. I would like to change the display length programmatically after the table has initialized.

My custom data table widget lives inside a modal. When I resize the modal I resize the datatable. I would like to also adjust the Display Length in the same resize function.

resize: function( event, ui ) { 
  $('.dataTables_scroll').css('height', magicRation * $('#modal').height() );
  $('.dataTables_scrollBody').css('height', $('.dataTables_scroll').height() - 91 );
},
var displayLength = Math.floor($('.dataTables_scrollBody').outerHeight() / $('#DataTables_Table_0 > tbody  td').first().outerHeight());
1 Answers
Related