How print in Jquery / Datatables [closed]

First, you should NEVER post minimized code – it’s not easy to read, and therefore, it’s hard for people to answer your question. This will lead to a negative scoring question.

Datatables are pretty easy to use, and there are plenty of examples at their website (datatables.net) for this. For this particular problem, try https://datatables.net/examples/basic_init/hidden_columns.html

Assuming you are not doing server side processing, it should be as simple as this:

$(document).ready(function() {
    $('#example').DataTable( {
        "columnDefs": [
            {
                "targets": [ 2 ],
                "visible": false,
                "searchable": false
            },
            {
                "targets": [ 3 ],
                "visible": false
            }
        ]
    } );
} );

Given your list, this would print

  • Name
  • Lastname
  • Action

Email would still be searchable, but age would not.

If you only wanted to remove only the action column, as your question suggests, try this:

$(document).ready(function() {
    $('#example').DataTable( {
        "columnDefs": [
            {
                "targets": [ 4 ],
                "visible": false
            }
        ]
    } );
} );

Leave a Comment