Skip to content

Adding/Removing widgets from table #112

Closed
thezoggy opened this Issue Jul 23, 2012 · 5 comments

2 participants

@thezoggy
Collaborator

say I have a table, with:

widgets: ["zebra", "filter", "resizable", "columns", "stickyHeaders"],

then i have a button where I do:

 $("table").data("tablesorter").widgets = ["zebra"]; 
 $("table").trigger("applyWidgets");

should that not remove all widgets except zebra?

@Mottie
Owner
Mottie commented Jul 23, 2012

That is referring to tablesorter version 3 that I sent you. In that version, the widgets are set in the config:

$('table').data('tablesorter').config.widgets = ['zebra']; // v3 only
$('table').trigger('applyWidgets');

In the current version, use:

$('table')[0].config.widgets = ['zebra'];
 $('table').trigger('applyWidgets');

(updated) or as you said, use:

$('table').data('tablesorter').widgets = ['zebra'];
$('table').trigger('applyWidgets');
@Mottie
Owner
Mottie commented Jul 23, 2012

Actually, I was wrong.

$('table').data('tablesorter').widgets = ['zebra'];

Will work, leave out the .config... see this demo, I've added this example to my last comment.

@thezoggy
Collaborator

thanks, i should have more time later today to play around with stuff

@Mottie
Owner
Mottie commented Jul 24, 2012

I'm working on adding a remove function for each widget... they won't work with older versions of tablesorter, but in the upcoming version you will be able to trigger a refreshWidgets event which will remove unused widgets and update selected widgets. With an additional flag, the same triggered even will remove all widgets and reinitialize the selected widgets.

// removed unused widgets and update current widgets
$('table').trigger('refreshWidgets');

or, send a true flag along with the event:

// remove ALL widgets, then reinitialized current widgets
// current widgets are found in the `widgets` option
$('table').trigger('refreshWidgets', true);
@Mottie
Owner
Mottie commented Sep 27, 2012

Ok, version 2.4 is up and running... see the refreshWIdgets documentation. It is used the same as I mentioned above.

@Mottie Mottie closed this Sep 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.