How to add a checkbox to a table view

The question of how to add a checkbox to a table view has come up before:

The answer (attaching an action to a blank virtual column) was provided but as I don’t think the implementation is completely self evident, I thought I’d provide a little example and explain the steps one needs to follow to implement it.

First, here’s an image to illustrate the goal:

28

The empty checkbox and the checked checkbox are the same action. When the action is invoked it changes a column called “Check” from either “FALSE” to “TRUE” or “TRUE” to “FALSE”.

The action uses the following expression:

if([Check]=TRUE,FALSE,TRUE)

It has been attached the an empty text column (a virtual column). In this case, I called the column “Blank” but the name could be anything because the name of the column will not be shown in the table.

Next, attach the action to the blank column as follows:

To get the action to appear to be an empty checkbox when the column “Check” is “FALSE” or blank, choose the following icon for the action:

26

Now, go to UX --> Format rules and make the following format rule:

This way, when the action does it’s work and changes the “Check” column value to “TRUE”, the icon will change to a box with a check in it. It will revert back to an empty box (and the “Check” column value will go to “FALSE”) if you tap on the action again.

Now, how do we place the action within the table? Here’s the column view for the table view (UX --> Views):

This places the check after the “Name” column. If the “Blank” column is placed after the “Number” column, it will look like this:

12

Well, that’s about it. The only thing I couldn’t figure out how to do is to give the blank action column a header. The action will “attach,” in a sense, to the column that precedes it but I can’t figure out any way to avoid having blank space in the header position above the action.

P.S. This is one of several tips I have put together about how to work with table view. Here’s a link to the rest:

10 Likes

Awesome @Kirk_Masden Thank you very much.
I think your column [Blank] is of Type Yes/No ?

Thanks for your support and encouragement, @Fabian! To be honest, I’m having trouble remembering how I set that column and I seem to have erased this little test app. :frowning:

In another app of mine (the main one I have been working on for some time), I make it a “Thumbnail” virtual column that displays images based on the combination of two checkboxes as follows:

37%20AM

This is accomplished with the following expression:

ifs(
and([Cram]=TRUE,[Cram only]=TRUE),
http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram01a.png”,
[Cram]=TRUE,
http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram02a.png”,
[Cram only]=TRUE,
http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram03a.png”,
1=1,“http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram%20thumbnail%20blank.png”)

I’m not sure if I did this the right way, but the last “1=1” means that if none of the other IFS are true than use the transparent blank thumbnail.

I haven’t checked but I think the column to which the checkmarks are attached can be almost any kind of column.

1=1 is really a cool idea :grinning:. I didn’t know that this would work.
I think you could wrap it also in an If statement like:

if(
and([Cram]=TRUE,[Cram only]=TRUE),
“http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram01a.png”,
ifs(
[Cram]=TRUE,
“http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram02a.png”,
[Cram only]=TRUE,
“http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram03a.png”),
“http://www2.kumagaku.ac.jp/teacher/~masden/2017/ICS/cram/Cram%20thumbnail%20blank.png”)

In this case you say: take the blank thumbnail as the ELSE.

2 Likes

Now I will explain how to use check boxes in Table view.
Thanks for the explanation @Kirk_Masden, I tried the way and I got it successful.

My excel has columns Name No and Check, make Check as Yes/No

Goto Behaviour and click on Add New Action

set the column to Check and provide formula if([Check]=TRUE,FALSE,TRUE)

In appearance make action icon to square and make prominence as Display Inline

Now click Attach To Column and provide our column Check and as you can see we got a check box

Now goto UX -> Format Rules and create new format rule

in formula tab write [Check] = TRUE
next provide our newly created action to it
for icon use check-square

we can check and un check now

App Link: https://www.appsheet.com/start/960ce629-97dd-4265-a01b-680a3a280045

4 Likes

@Kirk_Masden Thanks for your work on this. Is this still the best way to do this? Seems like it should be native to AppSheet but I guess it’s not.

1 Like

Thanks Lucinda! I agree that there should be a native function. Please vote for the following and checkout other workarounds discussed on this page:

2 Likes

Voted. I saw Thiery’s response that it’s being worked one. Looking forward to it.

2 Likes