Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override tablesorter instance #135

Open
Ynhockey opened this issue Aug 15, 2017 · 1 comment
Open

Override tablesorter instance #135

Ynhockey opened this issue Aug 15, 2017 · 1 comment

Comments

@Ynhockey
Copy link

I already asked this on SO a while ago but got no answers, so trying my luck here:

I have a general tablesorter class, .tablesorter, with which I associate the simplest tablesorter:
$('.tablesorter').tablesorter();

However, in some cases I want to override this, for example with disabled sort headers, etc. However, this doesn't seem to work, and I am only able to get the original behavior. Is this normal? Is there anything I can do to make this work?

Thanks in advance.

@Mottie
Copy link
Collaborator

Mottie commented Apr 24, 2018

Hi @Ynhockey!

I'm not sure if this'll answer your question, but if you don't want a table to be made sortable, don't include the tablesorter class name.

To disable a header cell initially, set the headers option to false (demo)

$("table").tablesorter({ 
  headers: { 
    0: { sorter: false }
  }
});

To disable specific columns dynamically, toggling the header cell's sortDisabled property (demo), then apply a sort:

$('table').tablesorter();

$('button').click(function(){
  // disable sorting for a specific column
	$('th')[1].sortDisabled = true;
  // remove any sorting
  $('table').trigger('sorton', [[[0,2]]]);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants