need a more performant use of the api

need a more performant use of the api

ajoslin103ajoslin103 Posts: 20Questions: 4Answers: 0
edited August 2016 in Free community support

given an array of booleans indicating intended column visibility

is there a faster way to set the visibility of each column?

$.fn.dataTable.Api('#table-1').columns().every(function(ndx){
this.visible(weeksVisible[ndx]);
});

thanks,
Al;

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin
    Answer ✓

    Yes, pass false as a second parameter to column().visible(). Otherwise it is doing the full redraw calculations every time around that loop!

    Call columns.adjust() once the loop has completed.

    Allan

This discussion has been closed.