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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

cvroque opened this issue · comments

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!

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

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.

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!

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!

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

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

Then I wonder why this issue is still open.