Possible to modify subset of dataTable settings based on class?

Possible to modify subset of dataTable settings based on class?

jeffwjeffw Posts: 38Questions: 5Answers: 0
edited April 2013 in General
Is it possible to modify pre-existing dataTables by passing in additional objects? Some features I want on all tables, others (e.g. pagination) i only want on certain tables, that have a css 'paginated' class.

I'm using something like the code below but is it possible to instead modify the dataTable() settings for certain selectors, instead of having to re-initialize?

thanks,

Jeff

$(table).dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": false
});


$('table.paginated').dataTable({
"bPaginate": true,
"bLengthChange": true,
"bFilter": false,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"iDisplayLength": 20, // default 20 rows
"aLengthMenu": [[20, 50, 100, -1], [20, 50, 100, "All"]]
});

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    > Is it possible to modify pre-existing dataTables by passing in additional objects?

    No - features cannot be enabled and disable on-the-fly. You would need to destroy the table (using bDestroy ) and then reinitialise it with the new features that you want. Sorry :-(. Adding the ability to change features on-the-fly would add a lot of code overhead to DataTables and remove the ability to modularise the code, which is going to make up a large part of 1.11.

    Allan
  • jeffwjeffw Posts: 38Questions: 5Answers: 0
    Thanks Allan. Totally understandable that this enhancement would bog it down. It works great as is.
This discussion has been closed.