سؤال

Normal tablesorter can be initialized using this command

$(function(){

  $tblSorter = $("table").tablesorter({
    widthFixed : true,
    showProcessing: true,
    headerTemplate : '{content} {icon}',
    widgets: [ 'uitheme', 'zebra', 'filter', 'scroller' ],
    widgetOptions : {
      scroller_height : 300,
      scroller_barWidth : 17,
      scroller_jumpToHeader: true,
      scroller_idPrefix : 's_'
    }
  });

});

However how can I set widgetOptions if I reapply scroller, after removing it:

Code for removing scroller as pointed by @mottie (Thank You)

$tblSorter.trigger('refreshWidgets', [true, true]); //REMOVE ALL WIDGETS
$tblSorter[0].config.widgets = ['zebra', 'columns']; //ADD ONLY ZEBRA and columns
$tblSorter.trigger('applyWidgets');

Code for putting scroller back into the tablesorter, with widgetOptions:

$tblSorter.trigger('refreshWidgets', [true, true]); //REMOVE ALL WIDGETS
$tblSorter[0].config.widgets = ['zebra', 'columns', 'scroller']; //add also scroller
$tblSorter[0].config.widgetOptions  = {
   scroller_height : 500,
   scroller_barWidth : 17,
   scroller_jumpToHeader: true,
   scroller_idPrefix : 's_'
};
$tblSorter.trigger('applyWidgets');

This is not working.

Thank you for any help.

هل كانت مفيدة؟

المحلول

Actually the scroller widget needs a lot of work... it is completely missing the code to remove it from the table. You can do that using this code:

// remove scroller widget completely
$tblSorter.closest('.tablesorter-scroller').find('.tablesorter-scroller-header').remove();
$tblSorter
    .unwrap()
    .find('.tablesorter-filter-row').removeClass('hideme').end()
    .find('thead').show().css('visibility', 'visible');
$tblSorter[0].config.isScrolling = false;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top