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
198 stars 23 forks source link

Sorting not working (maybe bug, maybe FR) #126

Open AleXSR700 opened 6 months ago

AleXSR700 commented 6 months ago

It seems that sorting only works on attributes that are being displayed in the table rather than all attributes of the entity that is being displayed.

I am displaying only the state but this seems to mean that I can only sort by state and not by friendly_name of the entity who's state I am displaying.

  - type: custom:flex-table-card
    entities:
      include:
        - sensor.eq3*valve
    sort_by: friendly_name
    columns:
      - name: <div>Valve<br><br>%</div>
        data: state

So even though the included entities all have friendly_names, sorting does nothing except when sorting by state (the only attribute being displayed).

Ideally, like in auto-entities, sorting should be possible by any attribute of the entities selected in include.

Would that be possible?

Or is that maybe even the intended way?

Thank you Alex

ildar170975 commented 6 months ago

It seems that sorting only works on attributes that are being displayed in the table rather than all attributes of the entity that is being displayed.

Seems to be by a design. As it was specified in Docs:

image

@daringer Is it an intended behaviour?

@AleXSR700 You may add a column with "friendly_name" & then hide it. Or (could be better) use auto-entities as a filter & specify sort there. Plenty of ways.

AleXSR700 commented 6 months ago

@ildar170975 I had tried adding friendly_name and then hiding it, but it seems my way of hiding was incorrect because I could not find a way to actually hide it. Only to basically create an empty friendly_name column and replacing all characters, i.e. creating an empty column. However, sorting by friendly_name does not sort by friendly_name but actually sorts by the modified friendly_name. So using e.g. modify: x.replace(/./g, ' ') creates an empty column but since there are no more characters to sort by, the sorting does not work. Is there a way of creating a column and hiding it?

But I now saw that there is a feature hidden: true, so that should do the trick :) EDIT: I saw the instructions on sorting, but essentially the sorting can be performed by any of the columns' attributes. So no the column's attribute but columns' attributes. So I guess yes, the instructions suggest that the sort order can only be based on one of the attributes used in the column.

That would of course, if true, turn this "issue" into a "feature request" :)

AleXSR700 commented 6 months ago

But I now saw that there is a feature hidden: true, so that should do the trick :)

Yes, did not see that originally -.-

So I would say it is now a feature request to be able to sort by any attribute of the entities specified, even if they are not in any column.