Hide a column in datatables

1

I have a table in datatables, which has 5 columns and one of them is an id that I want to hide the user, and it is soon in the first column after in the fifth column I have a button where I have the state but to change the state of knowing the id that I can get from column 1 but I want to hide the column and find the value in it. Is it possible?

    
asked by anonymous 24.02.2017 / 00:42

2 answers

1

Instead of putting visible: false in columnDefs try to put in columns

var table = $('#table-coletores').DataTable({
    processing: true,
    serverSide: false,
    responsive: true,
    lengthMenu: [[10,50,100],[10,50,100]],
    ajax: '{!! route('datatable.coletores') !!}',
    language: { 
        'url' : '//cdn.datatables.net/plug-ins/1.10.13/i18n/Portuguese-Brasil.json',
    },
    columns: [
        { data: 'name' },
        { data: 'tracking_code' },
        { data: 'status_formatted' },
        { data: 'days_left' },
        { data: 'customer_name' },
        { data: 'price_day' },
        { data: 'action', class: 'text-right', visible: false },
    ]
});

As in the last column, I just tested here and it worked using version 1.10.13

    
24.02.2017 / 13:18
0

I found this documentation on the datatables site :

Add the "visible": false attribute:

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