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

[Feature Request] Show empty/0/null instead of "undefinedundefinedundefined" #74

Open cvroque opened 2 years ago

cvroque commented 2 years ago

First of all, thanks for this amazing card. It's the best way to see data between atributes in various entities.

I'm building some cards to check on devices and I end up having issues when these devices don't all have the same atributes. There's the option to use strict: true but I actually want to see all devices. The problem is that makes the table look worse (last column):

image

Now, when it comes to numbers, I managed to fix using the modify argument like this modify: parseInt(x) || 0 and it works:

image

But JS is pretty new to me and I don't know how to make something similar to fix string or dates, or how to just replace "undefinedundefinedundefined" with an empty column. Anyone had similar issues and got tips?

So yeah, my request would be to solve "issues" like this directly in the card.

Thanks in advance!

daringer commented 2 years ago

yeees, this can be painful and tedious. There is quite some time now a (yet) minimal set of formatters, which you can simply choose for your column to be applied.

See the config reference at the bottom: https://github.com/custom-cards/flex-table-card/blob/master/docs/config-ref.md And inside the advanced formatting guide is an example: https://github.com/custom-cards/flex-table-card/blob/master/docs/example-cfg-advanced-cell-formatting.md

cvroque commented 2 years ago

yeees, this can be painful and tedious. There is quite some time now a (yet) minimal set of formatters, which you can simply choose for your column to be applied.

See the config reference at the bottom: https://github.com/custom-cards/flex-table-card/blob/master/docs/config-ref.md And inside the advanced formatting guide is an example: https://github.com/custom-cards/flex-table-card/blob/master/docs/example-cfg-advanced-cell-formatting.md

Thanks, somehow I missed that. Sadly the formatters don't deal with unavailable data, but I'll try other options with the modify and contribute back at a later time.

daringer commented 2 years ago

at this point they don't, but there is clearly the plan to allow applying multiple formatters, easily there could be one who hides undefined if encountered...

edit: and btw. not you missed them, moreover they are inside the code for i.d.k. how long and indeed I forgot them until I read you issue and had the fantastic idea to introduce formatters, lol - oh wait, what? I already did, coool!

cvroque commented 2 years ago

I ended up using this to change "undefinedundefinedundefined" to empty columns:

modify: if(x.length == 0){""}else{x}

It worked for strings, numbers and date.

image

I'm quite amateur on JS, but maybe this could be added as formatter?

Thanks again!

bcutter commented 1 year ago

modify: if(x.length == 0){""}else{x}

That is a great little workaround, glad I found it. Thank you.

ildar170975 commented 1 year ago

Then I wonder why this issue is still open.