Hello, I have a Products table with a column “Name” and another “is_organic_food”.
”is_organic_food” is typically a toggle column.
However, when I add products to the table, I usually don’t know right away if the product it organic or not.
Hence, I’d like to keep this field unfilled, and to distinguish it between “unfilled” and “filled with False” states.
In C++, I would use std::optional.
In python, I would use None, False, True.
How would you do that in grist ?
I could use a column with “choice” type and 3 choices. But I suspect there could be a more generic alternative (that would work numeric and text columns too), that would better inegrate with the nice check box/switch button GUI.
A choice column would seem the most intuitive option to me. After all, between stating “yes”, “no”, or “don’t know”, you really just have a choice. But I don’t really see a way around this, either. Once you set the col type to bool, Grist will strictly keep it that way, i.e. the cells in that column cannot technically ever be None.
They explain a trick: set a trigger formula “=None”, triggered on New record. I tried it. It works for Integer columns : the default value is then None instead of 0, which indicates the field is initially unfilled.
Alas this trick does not work work for toggle columns, I don’t know why.
Another, more complex, workaround would be to add another column to store whether or not the value is filled, and set it from a trigger formula, triggered on record changes.
This seems too complex & hard to understand for users.