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

Impossible to differentiate between "appened" sorts and user-initiated sorts #1558

Closed
GHLover opened this issue Jun 18, 2018 · 3 comments
Closed

Comments

@GHLover
Copy link

GHLover commented Jun 18, 2018

The Goal
It often makes sense to control the sort of a grid when the user-selected sort produces values of the same sort value. For example, imagine a table listing Country, State, and GDP. If a user selected to sort by Country, it would produce a grid with a sort that matched many rows based on Country, so within a particular country it is not being usefully sorted as it is sorted at random.

So, to help the user out, appendSort is used to sort by GDP as a secondary attribute. This is merely a convenience for the user.

The Problem

Currently, appendSort are treated as if they are user-inititated. This means that "tablesorter-header[Asc/Desc]" are added to the column. As a result, due to formatting, it makes the user beleive THEY selected to sort by State when in fact they did not. It is very confusing situation because the appendSort is in the background done just as a convenience for the user.

Solution?

It would be good if any sorts that were done as a result of appendSort or non-user action gets another css class so it can be differentiated. For example, tablesorter-headerAppendSorted. This way we can choose to highlight or not highlight this column. It is 100% backwards compatible with current behavior so will not cause undo issus for people who upgrade. And, it gives people who do not want the user to know sorting is being done in the background on their behalf a way to hide it.

@Mottie
Copy link
Owner

Mottie commented Jun 18, 2018

Hi @GHLover!

That sounds like a reasonable request. I'll add it to my to-do list.

@Mottie
Copy link
Owner

Mottie commented Jun 19, 2018

Updated in the master branch...

So instead of adding more class names, I instead added a data-attribute of data-sortedBy:

The value can be:

  • 'user' (renamed from 'mouseup' event) when a column is sorted by a user.
  • 'sort' when a column is sorted by triggering a sort event on the header.
  • 'sorton' when a column is sorted using the sorton method.
  • 'sortAppend' when a sorted column is added by the sortAppend option.
  • 'sortForce' when a sorted column is added by the sortForce option.

There may be other values that I can't think of right now because the value is set from the event.type; but not the 'sortAppend' and 'sortForce' values.

@Mottie
Copy link
Owner

Mottie commented Jul 12, 2018

This is now available in v2.30.7 - see the docs for config.sortVars.

@Mottie Mottie closed this as completed Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants