Adding/Removing widgets from table #112

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

Comments

Projects
None yet
2 participants
@thezoggy
Collaborator

thezoggy commented Jul 23, 2012

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

This comment has been minimized.

Show comment
Hide comment
@Mottie

Mottie Jul 23, 2012

Owner

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');
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

This comment has been minimized.

Show comment
Hide comment
@Mottie

Mottie Jul 23, 2012

Owner

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.

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

This comment has been minimized.

Show comment
Hide comment
@thezoggy

thezoggy Jul 24, 2012

Collaborator

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

Collaborator

thezoggy commented Jul 24, 2012

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

@Mottie

This comment has been minimized.

Show comment
Hide comment
@Mottie

Mottie Jul 24, 2012

Owner

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);
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

This comment has been minimized.

Show comment
Hide comment
@Mottie

Mottie Sep 27, 2012

Owner

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

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