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

Sort::link() - three states toggle #26

Open
Exerionius opened this issue Apr 7, 2017 · 12 comments
Open

Sort::link() - three states toggle #26

Exerionius opened this issue Apr 7, 2017 · 12 comments
Labels
type:feature New feature
Milestone

Comments

@Exerionius
Copy link

Sort Widget supports only two toggle states: first is default sorting, second is opposite to default sorting. It's unable to reset sorting by some field using Sort::link().

Link should have three states: default sort ->opposite sort -> no sort -> default sort -> opposite sort -> no sort ... etc., including the multisort.

@samdark
Copy link
Member

samdark commented Apr 7, 2017

There's no such thing as no sort. Results are always sorted somehow.

@bizley
Copy link
Member

bizley commented Apr 7, 2017

This might get handy only in case where you can sort by multiple columns. For single column sort this is pointless.

@yii-bot
Copy link

yii-bot commented Apr 7, 2017

Thank you for putting effort in the improvement of the Yii framework.

Unfortunately a use case is missing. It is required to get a better understanding of the issue and helps us to determine the necessity and applicability of the suggested change to the framework.

Could you supply us with a use case please? Please be as detailed as possible and show some code!

Thanks!

This is an automated comment, triggered by adding the label pr:missing usecase.

@Exerionius
Copy link
Author

Yes, for single column sort it may be pointless.
But in a multisort case when a GridView is sorted by one particular column other columns may be in chaotic order. For example: when you sort table by some string column or especialy calculated/related field, the ID field may be unsorted at all (I can't provide screenshots for a moment, because example project is left on workplace until monday).
In some cases it will be usefull for the user to remove some of the sort GET parameters to restore previous state of sorting they had. Because toggling sort by additional column sometimes does not return view to the state it had before sorting by that additional column. Sure thing you can just manually edit an address bar to remove unnessesary sort parameters, but it will be much more convinient if Sort()::link() had three state toggle.

My point is: when a multisort is enabled there are cases when toggling back and forth by additional column(s) does not return resulting table view to the state it had before sorting was applied by this column. So user clicks sorting by second column and after this moment he is unable to return his view to previous state because toggling aplies sorting anyway, and he had to reload the whole page and start applying sorts from the beginning.

@samdark
Copy link
Member

samdark commented Apr 7, 2017

OK. That makes sense but it should be optional and used only when multiple columns are used.

@bizley
Copy link
Member

bizley commented Apr 7, 2017

How do you propose to handle this because user does not expect third click to remove sorting on the column.

@samdark
Copy link
Member

samdark commented Apr 7, 2017

With a special × icon?

@bizley
Copy link
Member

bizley commented Apr 7, 2017

Maybe we could add arrow icons as well to quickly get the desired sorting order?

@Exerionius
Copy link
Author

Both sort asc and sort desc have their own css styles applied to links with bootstrap glyphicons, so why not apply some css for third state?

Regarding:

user does not expect third click to remove sorting on the column

... when I was clicking sort for the first time in Yii and it didn't removed on third click, I was surprised. So, it's personal perception - some users expects this, while others don't.

@bizley
Copy link
Member

bizley commented Apr 8, 2017

when I was clicking sort for the first time in Yii and it didn't removed on third click, I was surprised.

This is interesting. What other software uses that approach?

@Exerionius
Copy link
Author

Angular UI grid, if I'm not mistaken.

@ptheofan
Copy link

ptheofan commented Jul 7, 2017

The best sorting approach is the one the users are already trained with.

People are already trained in Google Sheets, Excel, Analytics, AdWords, and all myriads of applications out there (Amazon, eBay, etc).
On top, by default OS grid sorters are 3 state. Default, Ascending, Descending (MFC, .NET, Cocoa)

What is Default Sort Order?
Default stands for whatever sort order the software itself (developers) figured out is the best. Usually this is a complex sort algorithm. ASC and DESC are there just for the convenience of the user.

How Should ASC/DESC Sort Order Work?
It should adjust the SORT by placing as FIRST criteria the user attribute of choice and glue as second, etc. the default sort order.

Example
Default Sort

  1. CreatedAt DESC
  2. PaymentOptionScore DESC
  3. Price DESC

When user clicks Ascending on Name this should turn into

  1. Name ASC
  2. CreatedAt DESC
  3. PaymentOptionScore DESC
  4. Price DESC

By eliminating the Default it blocks the user to his 2 states not allowing him to easily and quickly go back to the Application Defined best sort option.

Anyone has a patch for Sort class?

@samdark samdark transferred this issue from yiisoft/yii2 Apr 24, 2019
@samdark samdark transferred this issue from yiisoft/view Sep 12, 2019
@samdark samdark added the type:feature New feature label Sep 27, 2024
@samdark samdark added this to the 2.0 milestone Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature
Projects
None yet
Development

No branches or pull requests

5 participants