Colorize Text Field Based on Value in Boolean

101 views
Skip to first unread message

Randy Flinn

unread,
Jul 29, 2025, 11:22:56 AMJul 29
to mementodatabase
I have a library that contains a Boolean and text field.  Is there a way to change the color of the text field based on the result of the Boolean (i.e., True = Green, False = Red)?

Mmm

unread,
Jul 29, 2025, 4:25:03 PMJul 29
to mementodatabase
Раскрашивать значение поля по значению другого поля нельзя.

Пример обходного решения:
Дополнительное поле JS, которое повторяет текст из исходного текстового поля и добавляет точку если логическое поле True или восклицательный знак (для False).
Изменение цвета определяется по "содержит" точку (текст зелёный) и "содержит" восклицательный знак (текст красный).

Some text.
Some text!

Тестовая библиотека:

Если дополнительное поле не приемлемо:
Создайте триггер, который будет отслеживать изменение логического поля и перезаписывать исходное поле.

Точка и восклицательный знак взяты для примера.
Возможно нужны другие символы или замена одной буквы в другой кодировке [aopy] латиница и [аору] кириллица.
Подходящие варианты нужно определять по образцам текста.

вторник, 29 июля 2025 г. в 18:22:56 UTC+3, rfli...@gmail.com:

Mmm

unread,
Jul 29, 2025, 4:29:34 PMJul 29
to mementodatabase
Результат:

Some text.
Some text!

вторник, 29 июля 2025 г. в 23:25:03 UTC+3, Mmm:

David Gilmore

unread,
Jul 30, 2025, 11:29:54 AMJul 30
to mementodatabase
What MMM said would work. I use a slightly different method, as it allows for much more flexibility. I create a separate field that is read only, and only visible in a list or card view. The real field is then only visible in the Edit view. I then have my "update"/"create" trigger fill that duplicate field with the information from the edit field, making any changes I want (such as color, combining multiple columns in a controlled way, reformatting the column, etc). I use this method a lot for the "description" field in the list view, and that allows me to customize what the description says (I also sometimes use this method for the "status" fields).

David Gilmore

unread,
Jul 31, 2025, 11:41:13 AMJul 31
to mementodatabase
In full disclosure, I do not use colored text, instead I prefer to use the foreground and background colors to indicate things. I do use special characters in my description field, to alert me to certain conditions in that entry. I do not use common characters like . or $ though, as it can be difficult to remember what they stand for (what does the "$" indicate now?). I use emojis instead. If you decide to use Mmm's suggestion, I would recommend the use of an emoji as your color indicator, as that can further identify what that color is indicating.

For those readers who are not familiar with the use of emojis, emojis are special ASCII characters that look like mini icons. The most common one is the "smiley face", and emojis are most often used in text messages. But since they are ASCII characters (UTF-8 (Unicode) character set), they can be used anywhere that regular ASCII characters are used. They can be placed in Memento text fields, in Javascript code (since they are characters, they need to be enclosed in quotes), and anywhere else text is used. Emojis use the expanded UTF-8 character encoding, similar to the expanded character set of languages such as Hanzi (Chinese) or Cyrillic (Slavic). There is a standard list of emojis that you can find online. The good news is that they are a standard. The bad news is not all systems or applications implement that standard. For example the warning emoji on my phone is an orange triangle with an exclamation point, where on the PC it appears as a white triangle with an exclamation point (if you are running Memento on multiple platforms (PC, Android, iOS), be sure that the emoji looks like you want it to on the different platforms. Also, not all keyboards support emojis. On my Android phone, the keyboard I use doss not, but the standard Samsung keyboard does. I just temporarily switch keyboards if I want to specify a new emoji, and then copy and paste the emoji after that.
Reply all
Reply to author
Forward
0 new messages