Showing posts with label Datatable.net - Get Column visible. Show all posts
Showing posts with label Datatable.net - Get Column visible. Show all posts

Saturday, March 7, 2020

Datatable.net - Get Reordering of the columns & Get Column visible

Datatable.net - Get Reordering of the columns & Get Column visible

Please add a button on the form like below
<a class="btn btn-success visiblecheck" href="javascript:void(0);" id="visiblecheck" value="test">visiblecheck</a>

Here is 'table' is variable of Datatable.net like

var table = $('#example').dataTable();


$('.visiblecheck').click(function () {
        alert(table.colReorder.order());
        var columnvisible = '';

        for (i = 0; i < table.columns().count(); i++) {
            if (columnvisible != '') {
                columnvisible += ',';
            }
            if (table.column(i).visible() === true) {
                columnvisible += '1';
            }
            else {
                columnvisible += '0';
            }
        }
        alert(columnvisible);
    });


table.colReorder.order() -  this will return the ordering of columns