DataTables / FixedHeader

Fix the header, footer, left or right columns of a table in place, to always show them when scrolling
http://www.datatables.net/
Other
75 stars 83 forks source link

fnUpdate() not working with ColVis #26

Closed tudor-sv closed 8 years ago

tudor-sv commented 10 years ago

I've encountered a bug when using FixedHeader(2.1.0) with ColVis. After toggling columns via ColVis, the table rows get updated, but the columns in the fixed header don't get updated. Calling fnUpdate /* FixedHeader / inside fnStateChange / ColVis */ didn't work. I've made the fix for my use case, but I'm not sure it doesn't break the functionality for other use cases.

Basicaly, I turned this:

/*
     * Function: fnUpdate
     * Purpose:  Update the positioning and copies of the fixed elements
     * Returns:  -
     * Inputs:   -
     */
    this.fnUpdate = function () {
        this._fnUpdateClones();
        this._fnUpdatePositions();
    };

Into this:

/*
     * Function: fnUpdate
     * Purpose:  Update the positioning and copies of the fixed elements
     * Returns:  -
     * Inputs:   -
     */
    this.fnUpdate = function (prm) {
        this._fnUpdateClones(prm);
        this._fnUpdatePositions();
    };

And in my implementation:

// fixed header
    var tableFH = new $.fn.dataTable.FixedHeader( myDataTable );

// updating the fixed header each time we toggle a column via ColVis
myTable
  .dataTable( {
        ... ,
        'colVis' : {
          ... ,
          'fnStateChange' : function(col, vis) {
            tableFH.fnUpdate(true);
          }
        },
        ...
  }

I'm also new to Git and GitHub. Might make newbie mistakes :) Awesome plug-ins, I'm happy to contribute !

DataTables commented 10 years ago

Hi - thanks for the comment here. Which version of DataTables are you using? If not 1.10, can you try 1.10. If you are using 1.10, can you link to a test case showing the issue please.

Allan

tudor-sv commented 10 years ago

Hi, with pleasure. I was using DT v1.9.4 and still see that it's the recommended version (docs were important to me also). No need to try the newer version, I had completed the project about a month ago. I'm only reporting this bug and fix now because I got cut up in work afterwards and now I want to contribute and learn to use git along the way.

DataTables commented 10 years ago

Super thanks. DataTables 1.9.4 is no longer being maintained - all development work is being done on 1.10 which will be released soon.

tudor-sv commented 10 years ago

You're welcome. It's the least I can do for a plug-in which was of tremendous help.

DataTables commented 8 years ago

Wow - long term bug this one - sorry! FixedHeader and the column visibility component of the newer Buttons extension works well now - example committed here: 36cb6d01f6a7909bd3662d27771fdf5c257cd039