Skip to main content

Posts

Showing posts with the label datatables.net

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';             }  ...

DataTables warning: table id=table1 - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

Issue -  DataTables warning: table id=table1 - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3 Solution - This error can often occur when trying to obtain a reference to the DataTable for working with the API. For example, you might have a function which will always try to create a DataTable instance by passing in options when created. Then you make a modification which calls this function on a table which has already been initialised and you get this error. In such a case, you will want to use the  $.fn.dataTable.isDataTable()  static method. This can be used to check if a table is a DataTable or not already: Javascript 1 2 3 4 5 6 7 8 if   ( $.fn.dataTable.isDataTable(  '#table1'   ) ) {      table = $( '#table1' ).DataTable(); } else   {      table = $( '#table1' ).DataTable( {      ...