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

Question/Feature request: exclude results from table? #20

Closed timdonovanuk closed 4 years ago

timdonovanuk commented 4 years ago

I see its possible to exclude entities, but is it possible to exclude a row based on a value (which may come from an attribute)?

Thanks.

daringer commented 4 years ago

no currently this is not possible, the way to implement this would likely be a skip_if config field, which might match with an arbitrary regex and if it matches with the contents of a specific cell, the full row should get skipped... mmh, will have to think about that...

another option currently possible would be to add another column (e.g., "show_row"), make hidden, make sure its content is either "0" or "1", finally apply a sorting based on this column and use max_rows to show just the rows containing "0". Downside of this approach would be an always fixed number of rows shown...

daringer commented 4 years ago

looks like skip_if is not even necessary, there already is the strict: property, it will not show any row containing null as value, means you could easily exploit this using modify:


type: 'custom:flex-table-card'
strict: true
title: sometitle
columns:
  - attr: node_id
    name: NodeID
    modify: '(x > 10) ? null : x'
  - name: Name
    prop: name

just tried it, works flawlessly. modify: is here just checking, if node_id > 10 and returns null, if true, this null is then leading to the row being deleted. As strict: true ensures that no rows with undefined or null cell-contents are shown.

daringer commented 4 years ago

closing due to inactivity, feel free to re-open if needed