FixedHeader works only after changing number of entries

FixedHeader works only after changing number of entries

bordin89bordin89 Posts: 5Questions: 2Answers: 0
edited November 2017 in Free community support

Hi all,

I added FixedHeaders to a DataTable. I don't know where I'm getting it wrong, but the plugin works only if I change the number of entries, it seems that it doesn't get triggered on load. This is the address of the page in question.

pvcbacteria.org/mywiki/pipeline-tables/Blastopirellula_marina_test.html

I'd appreciate any suggestion!

Thanks!

This question has an accepted answers - jump to answer

Answers

  • gyrocodegyrocode Posts: 126Questions: 6Answers: 30
    Answer ✓

    This occurs because your table is not visible when you initialize it.

    You need to use fixedHeader.adjust() method to recalculate the position of the table and redraw the fixed elements.

    From the official documentation:

    Note that if the DataTable is not visible, FixedHeader will effectively disable itself, returning the DataTable to its standard state. If the DataTable is then made visible again (for example in a tab), this method should be called to correctly draw the table.

    Use the code below for showPage() function.

    function showPage() {
              document.getElementById("loader").style.display = "none";
              document.getElementById("myDiv").style.display = "block";
    
              $('#table1').DataTable().fixedHeader.adjust();
    }
    

    See more articles about jQuery DataTables on gyrocode.com.

  • bordin89bordin89 Posts: 5Questions: 2Answers: 0

    That solved it! Thanks a lot!

This discussion has been closed.