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 on click: descending first, then ascending #468

Closed
alberto opened this issue Aug 6, 2015 · 15 comments
Closed

Sort on click: descending first, then ascending #468

alberto opened this issue Aug 6, 2015 · 15 comments

Comments

@alberto
Copy link

alberto commented Aug 6, 2015

By default, Smart-Table sort states are ascending, descending, default, in that order.

Is there a way to make the order: descending, ascending, default?

Please notice I am talking about the behaviour of any column when its header is clicked, not the ordering of the default column (st-sort-default).

@lorenzofox3
Copy link
Owner

No there is no way at the moment to change the order of the different states, I am sorry

@alberto
Copy link
Author

alberto commented Aug 8, 2015

I think it should be doable if you had a new attribute st-sort-descending="true" or something like that, which you could apply to any sortable column. Would you be open for a pull request to include that? I can give it a try. :)

In that case, I would also remove st-sort-default="reverse", separating the notion of ordering direction from that of the default sorting column.

@stanleyxu2005
Copy link

@alberto better change the order in config.

@alberto
Copy link
Author

alberto commented Aug 30, 2015

Thanks @stanleyxu2005 I didn't know you can change the order in the config. Anyway, I want to be able to make some columns descending first (e.g date) and others ascending first (category) so a global change doesn't fix my problem.

@angoras
Copy link

angoras commented Sep 4, 2015

I'm also very interested in this feature. Any suggestions on how to implement it? I'm an absolute beginner in Angular...

@jeffrey-roosendaal
Copy link

Please add support for this! It's the only reason I simply can't use it for my project, while I think it's the best and cleanest Angular table module. After trying most of them, Smart Table is by far the best/easiest solution, but I had to switch (back) to ng-table because of this :(

I suggest naming the attribute st-sort-initial, which accepts 'asc' and 'desc', and defaults to 'asc'.

@rkpatel0
Copy link

Would love this feature too!!!

@stanleyxu2005
Copy link

+1 I have a large table with 1k metrics records. Usually I want to see the largest throughput, but now I have to click column twice..

@timonwong
Copy link

FYI: hz-table directive (from OpenStack horizon project) have implemented default-sort and default-sort-reverse attribute
https://github.com/openstack/horizon/blob/master/horizon/static/framework/widgets/table/hz-table.directive.js#L78

@douglas-treadwell
Copy link
Contributor

timonwong, I looked at the code there and it seems to only reverse the initial sort. It doesn't seem like it would enable column-by-column default sort order reversal upon clicking each column. Please let me know if I'm wrong.

@douglas-treadwell
Copy link
Contributor

Here's an implementation. Until it's merged you can use that branch.

#608

@andy-dumbell
Copy link

+1 please

@lorenzofox3
Copy link
Owner

@andy-dumbell do you realize, it has been merged and it is already available ?

@andy-dumbell
Copy link

Thanks @lorenzofox3 I hadn't realised. Will try now. Cheers Andy

@lorenzofox3
Copy link
Owner

👍

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

9 participants