Change value displayed for boolean fields


Hi everyone.

I created a data collection including several fields set as boolean. Users use checkboxes to input values. But when I use a table to display what users entered, those fields show “Yes” or “No”.

Is it possible to change vales displayed from “Yes” to “✓”, and “No” to just an empty cell?

Rgds

Alfred

Hi Alfred,
I’m afraid that currently there’s no option to change it from “Yes” to “✓”. However, as a workaround, you can use image for that purpose (meaning a “✓” image instead of using a boolean field). If you wish to sort / query the collection based on this field, you can have two columns (the first one is image column and the other one is boolean column) and hide the boolean column from the table.

Good luck!
Tal.

One thing you can also look into is using the dataFetcher property of $w.Table (Table - Velo API Reference - Wix.com) to convert the boolean value in your dataset to the check mark image as Tal suggests which means you design the table to show the vectorImages you want (say “✓” and “✘”) and modify the data retrieved from the dataset by prefetching rows using the dataFetcher and setting the pageRows property to the modified row records after you replace booleans with the appropriate image.

Got it.
Many many thanks.

Maybe this question is a little off base, but you’re talking about the right thing for me. So I have a database with boolean check mark values, and I have a query that’s coded to count the boolean values. But, I am unsure of the values I’m suppose to use in the code for retrieve this…

wixData.query(‘NewYearSurvey’)
.eq(‘cardioSculpt’, [what goes here?] )
.count()
.then((num) => {
cardioCount = num;
})

Hi Brett:

When you are dealing with boolean values in the data collection you can only really rely on counting true values. false , is the negative although unless you specifically set the value to false the value could also be returned as null.

So to address this problem you need to use .eq(‘propertyName’, true) to find true values see the following:

wixData.query('NewYearSurvey')
 .eq('cardioSculpt', true)
 .count()
 .then((num) => { cardioCount = num; })

or to get negative (false) values you need to check for the opposite of .eq, so .ne(‘propertyName’, true)

wixData.query('NewYearSurvey')
 .ne('cardioSculpt', true)
 .count()
 .then((num) => { 
     cardioCount = num;
 })

NOTE: the work true in the above examples is without quotes of any kind because the words true and false are special words known as primitives in javascript.

Hope this helps.
Good luck

Hello, can you show me how the code look like, for this situation? i’m having the same problem, to present my results yes or no with a “✓” and “✘” inside the table rows. Thank you

can you please add code how to replace yes/no with icons