2
votes

I attached DataTable to one of my tables in application:

var productList = $("#productList").DataTable({});

Unfortunately it completely reorganized my table. It changed the way it looked and added some more unnecessary (for now) buttons.

I need only one particular feature of DataTables for now - KeyTable. Is it possible to disable by default all features that comes with DataTables? Then, I would enable only those that I need right now.

2

2 Answers

1
votes

You can do it like this:

var table = $('#example').DataTable({
    dom: 't',
    ordering: false,
    paging: false,

    keys: true, //enable KeyTable extension
});

The dom option is an easy way to enable/disable certain functionality. I've disabled ordering and paging, you may want to look at the available "feature" options and see if anything else needs to be disabled.

Also, you probably don't want to load the default CSS (jquery.dataTables.css), since I assume you have already styled your table.

0
votes

You can set the default properties like this. You can remove the unnecessary properties by setting false.

$.extend( true, $.fn.dataTable.defaults, {
  "searching": false,
   "ordering": false
} ); 

$(document).ready(function() {
   $('#example').DataTable();
});