Search code examples
datatablestablesorter

How to select maximum 7 columns in columnselector?


I am using tablesorter widget-columnSelector.js file.

By using columnselector at a time need to select maximum 7 columns.

Because my code have 12 columns in columnselector,If I select 12 columns at a time table going out of the screen.

I need solution By using columnselector select maximum 7 columns.

Thanks in advance for your help.


Solution

  • I've updated the columnSelector widget. Two options will be added in v2.27.0 (not yet released at the time of this post).

    • columnSelector_maxVisible - set maximum number of visible columns.
    • columnSelector_minVisible - set minimum number of visible columns.

    One caveat is that any disabled columns (not visible in the column selector) are not counted towards this min/max value.

    I set up this demo which is pointing to the code available in the master branch of my repository. Add a "columnSelector-disable" class to any of the columns to experience what I mentioned in the above caveat.

    $(function() {
      $(".custom-popup").tablesorter({
        theme: 'blue',
        widgets: ['zebra', 'columnSelector', 'stickyHeaders'],
        widgetOptions: {
          columnSelector_container: $('#columnSelector'),
          columnSelector_saveColumns: false,
          columnSelector_mediaquery: false,
    
          // set the maximum and/or minimum number of
          // visible columns (added v2.27.0)
          columnSelector_maxVisible: 3,
          columnSelector_minVisible: 1
        }
      });
    });