custom-cards / flex-table-card

Highly Flexible Lovelace Card - arbitrary contents/columns/rows, regex matched, perfect to show appdaemon created content and anything breaking out of the entity_id + attributes concept
GNU General Public License v3.0
213 stars 26 forks source link

Header sort doesn't work #149

Open Nickduino opened 4 days ago

Nickduino commented 4 days ago

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
EdLeckert commented 17 hours ago

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.