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

q-table - please add "sort direction" param to column definition #8527

Closed
Daemach opened this issue Feb 22, 2021 · 16 comments
Closed

q-table - please add "sort direction" param to column definition #8527

Daemach opened this issue Feb 22, 2021 · 16 comments

Comments

@Daemach
Copy link

Daemach commented Feb 22, 2021

Here's a video describing the problem: https://www.screencast.com/t/GtHFyqLMA

It would be wonderful if I could add an attribute as below that would set the default sort direction at the column level, rather than just once for the initial load in the pagination object:

{
  name: "globalblacklist",
  align: "center",
  label: "GBL",
  field: "globalblacklist",
  sortable: true,
  **sortDir: 'desc' || descending: true  //defines initial sort when column header is clicked**
},

Numeric columns are nearly always more useful sorted desc initially, whereas alpha columns are better sorted asc. This is the case whether the data comes from an array of objects or from an ajax call.

And since I'm stuck on Q1 at the moment, backporting it there would be great. Although having it in Q2 might be enough for me to make the switch...

@Daemach
Copy link
Author

Daemach commented Apr 21, 2021

I just wanted to mention that I know I can pass a custom sort function, but the asc/desc icons are problematic. When there is an asc icon (arrow pointing up) but the sort is desc, it looks broken. Visual cues are important, and consistency is perceived as quality in the financial services industry as everyone is very detail oriented.

@rstoenescu
Copy link
Member

Will be available in Quasar v2.0.0-beta.13 & Quasar v1.15.11: new prop (column-sort-order) and new "columns" definition prop (sortOrder).

Values: "ad" (ascending-descending) and "da" (descending-ascending). Default is "ad".

PS: thank you for being a sponsor.

@Daemach
Copy link
Author

Daemach commented Apr 25, 2021 via email

@Daemach
Copy link
Author

Daemach commented Apr 26, 2021

The sorting works. Thanks very much for adding this!

One very minor issue is that I would expect to see a down arrow when mousing over the column header of a column with a default descending sort. https://www.screencast.com/t/MpNdVZ76eHq When clicked, it does sort correctly and the arrow changes to point downward. Just confusing to see an asc hint and the sort be desc.

@rstoenescu
Copy link
Member

I know, but implementing that requires way too much overhead which honestly we're better off...

@vojvodics
Copy link
Contributor

vojvodics commented Feb 17, 2022

@Daemach or anyone having the same problem. You can easily fix this with CSS:

just add a desc-first in headerClasses if you are using 'da' sortOrder for that column.
Then, just add this:

th.desc-first:not(.sorted) .q-table__sort-icon {
    transform: rotate(180deg);
  }

@Daemach
Copy link
Author

Daemach commented Feb 19, 2022

@vojvodics Thanks for this suggestion. I appreciate it!

@Daemach
Copy link
Author

Daemach commented Mar 25, 2022

I tried implementing this today, but get the following error. Where am I going wrong?

image

@MilosPaunovic
Copy link
Member

Have you tried pasting it exactly as @vojvodics suggested?

th.desc-first:not(.sorted) .q-table__sort-icon {
  transform: rotate(180deg);
}

@vojvodics
Copy link
Contributor

@Daemach Sorry, initially I pasted the version for scss, so either copy the latest code, or just add <style lang="scss"> instead of <style>

@Daemach
Copy link
Author

Daemach commented Mar 25, 2022

Using your updated code worked. Thanks again for following up!

@Daemach
Copy link
Author

Daemach commented Mar 25, 2022

@rstoenescu this is an elegant, low-overhead solution. Can this be added to the code base so I don't have to manually add it everywhere?

@Daemach
Copy link
Author

Daemach commented Mar 28, 2022

@pdanpdan

@AlphaJuliettOmega
Copy link

AlphaJuliettOmega commented Oct 21, 2022

@rstoenescu is this feature in yet?
Closing the ticket before it's released makes it confusing

I'm on

"@quasar/app-webpack": "^3.6.1",

Columns marked sortable:true

      v-model:pagination="defaultPagination"

With this model:

    const defaultPagination = {
      sortBy: 'date', // matches column Name in Columns definition
      descending: true
    }

It sorts it fine when the page loads but all columns are locked now, can't switch to sorting on another column

@AlphaJuliettOmega
Copy link

Will be available in Quasar v2.0.0-beta.13 & Quasar v1.15.11: new prop (column-sort-order) and new "columns" definition prop (sortOrder).

I have the column-sort-order property pop up so I have typings for it, but it doesn't have anything to do with choosing which column is to be default sorted.

And my columns are still locked if I set my default like above.

What am I missing?

@maggie9595
Copy link

Still having this issue but the CSS above worked for me as a temporary fix.

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

6 participants