Answers for "show or hide columns in print datatable"

2

hide datatable columns using datatable predifine function

$(document).ready(function() {
    $('#example').DataTable( {
        "columnDefs": [ 
            {
                "targets": [ 2 ],
                "visible": false,
                "searchable": false
            },
            {
                "targets": [ 3 ],
                "visible": false
            }
        ]
    } );
} );
Posted by: Guest on May-24-2021
0

how to filter on a hidden column datatables

Plain text12345678910111213141516171819202122232425262728293031323334353637383940414243444546$(document).ready( function () {    $('#example').DataTable(    {                 responsive: true,        scrollY:'40vh',        scrollCollapse: true,        columnDefs: [        { targets: [0, 3, 4, 5, 7, 8, 9, 11, 12], visible: true},        { targets: '_all', visible: false },                 { width: "40%", targets: [5] }    ],                          "order": [[ 0, "asc" ]],        rowGroup: {                         enable: true,            dataSrc: 1,        },         initComplete: function () {            this.api().columns([1]).every(function () {                var column = this;                var select = $('<select><option value=""></option></select>')                    .appendTo( $(column.footer()).empty() )                    .on( 'change', function () {                        var val = $.fn.dataTable.util.escapeRegex(                            $(this).val()                        );                          column                            .search( val ? '^'+val+'$' : '', true, false )                            .draw();                    } );                  column.data().unique().sort().each( function ( d, j ) {                    select.append( '<option value="'+d+'">'+d+'</option>' )                } );            } );        }}         );     } );
Posted by: Guest on March-31-2021

Code answers related to "show or hide columns in print datatable"

Browse Popular Code Answers by Language