Code Snippets for Datatables.js | Examples and Formatting of tables

How Do You Do Stuff With DataTablesJS Tables

1. Turn off searching on columns 1 and 2

2. Shut off Filter arrows.

3. Set width (turn off autoWidth first)

Order rows by 5th column in ascending order.


    $(document).ready(function(){
        $('#contentcontrol').DataTable({
            autoWidth: false, 
            "columnDefs": [
                { "searchable": false, "targets": 0, "ordering": false },
                { "searchable": false, "targets": 1 },
                { "orderable": false, "targets": [0, 1] },
                { "width": '15px', "targets": [0,1,2,3,7] },
                { "width": '150px', "targets": [8,9] }
                
            ],
            "order": [4, 'asc']
          

       
        });
        moment().format();

Resources:

https://stackoverflow.com/questions/20196397/jquery-datatables-remove-sorting-arrows