Disable button when true - not seeming to work

Hello,

I'm trying to disable a button when the value of a field, in a selectedRow, in a table is empty - but, it seems to still be disabled, even when the field is not empty.

I guess this is likely just something wrong with my code, but any help you can provide is appreciated:

{{tbl_matrix_records.selectedRow.data.matrix_image_url.value === ""}

thanks,
Neil

When you hover over the value of
tbl_matrix_records.selectedRow.data.matrix_image_url.value - what is the value?
Maybe try the following:
{{tbl_matrix_records.selectedRow.data.matrix_image_url.value === "" || {tbl_matrix_records.selectedRow.data.matrix_image_url.value === null || {tbl_matrix_records.selectedRow.data.matrix_image_url.value === undefined}}

Thanks for the reply Scott.
I already tried null.... didn't work.....

So, when I hover over (using examples above) it shows:

"" = false
null = false
undefined = true

So it seems to be doing the 'logic' part for me, which isn't as intended......

That's odd because the following works for me - and the row you selected is the one with undefined data?

I believe so, if you look at original post with image - you can see the value of the field on the lefthand side

Very odd - but you are missing the second bracket in the disabled when true field...
} it should end in }}

Yes, I already spotted that - but it didn't make a difference.
It's not urgent, I'm sure I'll figure it out along the way.
Thanks again for your help,
Neil

So that looks correct - what happens when you select a row without an image url?

Yeah, seems correct to me as well.

Just chiming in to say you could also try using Lodash _.isEmpty();, especially if you wanted to try and capture multiple possibilities like "", undefined, and null.

1 Like

So - I thought i was testing that, but then realised I had populated also with a url..... I have now deleted that.

This is the message I get. Which I do not fully understand. Although, it seems to be that it is not able to process the 'null' value (as it is not a value? (shows as null in the code inspector window (sorry, don't know the name)

Screenshot 2023-01-17 at 18.53.24

Remove value
{{tbl_matrix_records.selectedRow.data.matrix_image_url === "" || {tbl_matrix_records.selectedRow.data.matrix_image_url === null || {tbl_matrix_records.selectedRow.data.matrix_image_url === undefined}}

1 Like

{{tbl_matrix_records.selectedRow.data.matrix_image_url === null}}

This did it! Thank you.

Actually, I removed value earlier, but my checking syntax (===) was wrong - and so I forgot to go back and try again.

thanks again, works as it should now,
Neil

Do you know,

is there a way to also disable this button if the table itself is empty?

tbl_matrix_records

Right now it is linked to the records that appear in that table. And, as it stands just now - if there are no records, the button is enabled.

You can try to hide the button if
{{tbl_matrix_records.data === null || tbl_matrix_records === undefined}}

Unfortunately that didn't work, but I was able to test it by looking at some other properties that might help - I added index to the second statement:

{{tbl_matrix_records.data === null || tbl_matrix_records.index === undefined}}

That at least got it working - but didn't function as normal because when records were added to the table it was still hidden.

Hi @maillme How about something like this that is checking if there is table data OR if the selected row's value is null?