0

I have DataTables and implemented the colReorder by dragging the checkbox element using .sortable() jquery-ui and everything is fine. But when I enable responsive:true the column is not ordering any more.

The reorder index is stored from DB and fetch using ajax..

var table = $('#example').DataTable({
    colReorder: true,
    responsive: true,
});
$.get('{{ url('/get-ranks') }}', function(response) {
    var ranks = response.data; // Output: 2, 3, 1, 0, 6, 4, 5

    table.colReorder.reset();
    var order = ranks.split(',').map(function(i) {
        return parseInt(i, 10);
    });

    table.colReorder.order(order);
});

The order variable gives the exact indexes, but still not working.

I just want to reorder the columns as well as the hidden columns from responsive.

I create a working test case here http://live.datatables.net/mulibiwi/1/edit

Marky
  • 55
  • 1
  • 2
  • 11

1 Answers1

0

Call

   table.columns.adjust()
  .responsive.recalc();

will recalculate the columns and redraw table.

Springgrass
  • 41
  • 1
  • 5