Clone only visible columns

Clone only visible columns

ProjectProject Posts: 1Questions: 1Answers: 0

Hi, i'm doing a datatable filter on head using the example Column filtering: https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html

I want to clone only the visible columns, is it possible? How can i do?

Thanks in advance
Luca

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited June 2018 Answer ✓

    Hi Luca,

    That example you gave is cloning a whole new header row, so that would be for all columns, whether visible or not.

    When it creates the input cells in the each() loop, you could test for visibility there with column().visible(), but it would be probably just as efficient to create it for all columns. The test would be something like:

    if ( table.column(1).visible() ) {
      // the setup for the input cell
    }
    

    Cheers,

    Colin

This discussion has been closed.