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

Header sort doesn't work #149

Open
Nickduino opened this issue Nov 12, 2024 · 2 comments
Open

Header sort doesn't work #149

Nickduino opened this issue Nov 12, 2024 · 2 comments

Comments

@Nickduino
Copy link

I got no answer on the community thread, so I'm trying here. I could not find similar issues on Github either.

If I leave the card alone (and let sort_by: state+ do its thing), It works. But if I click on the headers, I don't get the right sorting:

image

The "Distance" column sorts properly. The last one (which displays the age of the information) doesn't (even if I remove the prefix and show only numbers:

image

The sorting by price column doesn't work either if I remove sort_by: state+
I also tried sort_unmodified = true just in case: the behavior is the same

type: custom:flex-table-card
sort_by: state+
clickable: true
max_rows: 5
entities:
  include:
    - sensor.station_*SP98
columns:
  - data: entity_picture
    align: center
    name: ""
    modify: "'<img src=\"' + x + '\"style=\"height: 35px\">'"
  - data: fuel_type
    align: center
    name: ""
    icon: mdi:gas-station
  - data: address,city
    multi_delimiter: ", "
    align: left
    name: ""
  - icon: mdi:currency-eur
    data: state
    name: ""
    align: center
  - data: distance
    modify: x + " km"
    name: Distance
  - icon: mdi:calendar-clock
    name: ""
    data: days_since_last_update
    align: center
    prefix: J+
layout_options:
  grid_columns: full

@Nickduino Nickduino changed the title Sorting Header sort doesn't work Nov 12, 2024
@EdLeckert
Copy link
Contributor

It appears that column sorting requires a distinct name value. That's why the Distance column worked, whereas the other columns sorted the first column instead of the clicked column. So the workaround is to use names on the columns, instead of or with icons.

I will look into correcting this behavior in a future release, but I am not the code owner, so no guarantees.

@Nickduino
Copy link
Author

It appears that column sorting requires a distinct name value. That's why the Distance column worked, whereas the other columns sorted the first column instead of the clicked column.

I don't know how you realized that but kudos!

So the workaround is to use names on the columns, instead of or with icons.

One single space works (and you can display the icon, so it looks identical). Since columns need a unique name, it seems two spaces work for the second column (and, I assume, three if you have a third one).

I will look into correcting this behavior in a future release, but I am not the code owner, so no guarantees.

Thank you!

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

No branches or pull requests

2 participants