Launched: Set control value action

how do I set a control to a blank value. I want to clear the selection to nothing

1 Like

MyControl.SetControlValue('')

'' is the value for blank

Confusingly, SetControlValue can’t add Blank to a Lookup, only to a MultiSelectList

I fixed your doc so it works, but this caveat will still apply:

It doesn’t say “All”
image

Formula was:

SetControlValue([Select Projects Gobal], Projects.ListCombine(''))

If you wanted all the Projects, but without adding blanks:

SetControlValue([Select Projects Gobal], Projects)
2 Likes

Please Please Please, consider to add the blank and the select all values to the Set Control!
It would be incredibly useful use a button to reset all interactive filters!!

I end up creating tables to do more granular and interactive filtering just to use buttons to reset to all or to the first value.

4 Likes

This is awesome and something I was relieved to find was possible. Unfortunately, I’m quite new to this, so can’t implement what you’ve done. Could you post the screenshot of what you actually set-up via the Set Control Value action.

Specifically when I try to implement with the “Set Control Value” action, it only allows me to set up one action. It looks like yours triggers two actions, which is what I’d like to do as well. Does that mean you used a formula? If so, could you post that formula?

Hi John! I’m afraid it’s been quite some time since I set this up and am not even sure in which doc I did so anymore :slightly_frowning_face: So, apologies in advance if I’m not fully remembering the scenario correctly, but I spun up another doc to walk thru this :slight_smile:

Also, this functionality has improved in the past year or so, so hopefully this is even better!

Let’s say I have a table of foods, and each food can be assigned a Type like protein, vegetable, or fruit.

The first thing I’ll do is make sure my Type column is a select list, so that the only values in it can be the types I indicate above.

After clicking “New,” I’ll let the Coda magic pre-fill the selectable items based on what I have in the table already. (I could also type in new values, or use a table, but for simple use cases, I like this way.)

Why do I want a select list? Partly for data validation, and partly to have the type of control I want to filter my data.

So, next I’ll create an interactive filter on my Type column to allow me to filter based on selectable types of food:

By default, this will give me a select list control above my table. You can always click and drag it to a new location if desired, but above the table tends to be a convenient spot for it!

Here’s an example of me using the new control to filter my results only to Proteins:

Now I want to create a “Reset” button. To do so, I’ll type /set control value in the location on the canvas where I want to put my button, and choose that button type. Then, I’ll fill in my button settings:

  • A memorable name & label
  • Confirm the action is “Set control value”
  • Select the name of the control (interactive filter) I configured above – in this case it’s “Select Foodstuffs Type”
  • Set my value as listcombine(Foodstuffs.Type.Unique(),"")

So what the hanky is that formula?

Basically the syntax is: ListCombine([Name of the Table].[Column with the possible values].Unique(), " ")

What I’m telling Coda with that formula is:

  1. Look at this table
  2. Select a combination that includes (1.) the list of all of the unique values from the “Type” column, and (2.) blanks (aka " ")

^ Note, you can get away without the unique() part of the formula, but I find it’s a good habit to build as your tables get bigger and more powerful to optimize for performance by telling Coda: “Please only worry about the unique possible values, and not the values in each and every row of the table.”

Et voilá! Because this is a formula in a “Set Control Value” button type, it will set the control (aka, interactive filter) to all of the possible individually-selectable values–including blanks.

Screen Capture on 2022-03-09 at 20-10-21

4 Likes

@Andrew_Stinger Wow…how I’ve needed this!! Thank you!

2 Likes

Hi,
Thanks for the fantastic tutorial on how to filter table using button. May i ask , is it possible to do the same without via the interactive filter? That is, use button to directly control the filtering of the table

Hi @shushimi ,

The general answer to your question is “yes,” but there are a host of ways to do so based on your actual goals/criteria. The value of using the interactive filter method is that it creates a control that can easily be modified to update how the table is filtered.

If you’d like to explore options to filter via a button, you could consider using formulas in a new button. The “set control value” and “run actions” formulas are probably ones you’d want to gain familiarity with to do so: Coda | Formula library

Another tip is to play around with the interactive filter options, then go to your table Options > Filters and click the “f” icon to see the formula that the interactive filter is actually running. Then you can use that logic in a number of places, including a button.

2 Likes

Thanks for the hint!
I am in the midst of trying your suggestion. I never realize button can set formula, cos i look at the button’s actions dropdown list, and never saw an option for setting formula. Turn out i have to click a “f” icon in order to set formula. :joy:

Now the only remaining question is what formula to use. As you suggest, I try refer to the table to get the formula that the interactive filter is actually running , but realize that formula can’t be used. Cos the formula refers to the interactive filter control’s value, which i trying to avoid. I try modify the formula so that upon click the new button, it will control the table’s filter directly, but can’t get it to work, as i total newbie in coda formula. Anyway, will continue to explore on this. Thanks

1 Like

May i know why the action menu of a new button i create, do not have “display filter row” ? Or is this something that is missing, and hopefully Coda will add it in future

Hello @shushimi ,
Filters are set in a table, not in a button. That said, you can use checkboxes to control your filter settings (by using a switchif() in your filter). The checkboxes can be hidden and they can be set with a button, but I find it easier to display the checkboxes as switches and use them to control my filter.

If you share a dummy doc with a table and a description of what you would like the switches of button to filter, we can show you in your doc how it can be done.

I think there is no need for an extra button action to accomplish what you want. It would not be all that easy, because the button would ‘need to know’ which table to act upon and what to do with existing table filters. That would be rather complex.

2 Likes

Hello @joost_mineur

Thanks for the suggestion.

My ultimate goal is to : Provide a few buttons. When button A is in “pressed” state, the table will be filtered based on specific value. When button A is “unpressed”, the table will be unfiltered. Same for rest of other buttons.
I hope to achieve this , without involving intermediate widget (such as checkbox or dropdown list)

As part of the process of learning Coda, I try to learn how to achieve whatever i have in mind, rather than avoid it. But once i manage to achieve it, if it is really that complex, I would switch to other way of achieving the same goal.

I personally feel that Coda should provide button’s action or formula to filter the display of table’s rows, where we could provide the table name, column name, and the value to filter. Look like currently this is not possible, unless i provide an intermediate widget (such as checkbox or dropdown list).

Btw, I am currently already able to use button to set an interactive filter(dropdown list) to a value which in turn control the table filtering. Just that I thought Coda allows me to do the same without involving this interactive filter.

If there is a way (even if complex) to set the filter in the table to filter the table based on the “pressed” state of the button, hope can share with me how this can be done via
Test for a dummy doc.

1 Like

Hello @shushimi ,
What you want to do can’t, to my knowledge, be done in coda. But look at the alternative I put in your doc, I think it gives you a workable alternative. I can think of other solutions, but not without intermediate steps.
Of course you can reverse the working of the buttons by adding .not() in the filter after the name of the switches (checkboxes).
Greetings, Joost

1 Like

Thanks @joost_mineur ! Have just took a look at your suggestion, and learn a new api “switchif”.

The formula for the table filter is
switchif(
FilterTag1 and FilterTag2,thisRow.[Column 2].Contains(“Tag1”,“Tag2”),
FilterTag1,thisRow.[Column 2].Contains(“Tag1” ),
FilterTag2,thisRow.[Column 2].Contains(“Tag2”)
)

Based on the above, I can forsee that if i have 5 checkboxes, that mean my formula will now become more complex with different permutations e.g tag1 (ON), tag2(ON), tag 3(OFF), tag 4 (OFF), tag 5(OFF). So wonder if coda has a simpler way to handle such situation.

For my use case, might not be an issue, cos i intend to allow only one checkbox turn on, and the rest should auto turn off.

  • There also seem to be no menu option to hide the checkbox.
1 Like

You can hide the checkboxes on a hidden support page and control them with buttons. Each of your five buttons can reset al the other switches and just set one that belongs to the specific button if you only want to filter based on one button.

And indeed, you can’t hide buttons or controls or checkboxes. I guess you have to accept some tradeoffs if you want to work in this no- or low-code environment.

3 Likes

@Andrew_Stinger For some reason I get “[values] is not a valid value for lookup control type.” When I use ListCombine([Name of the Table].[Column with the possible values].Unique(), " ")

*Clarification: Is it because I’m using lookups for the columns instead of a manual Select From List?

1 Like

I’m afraid without seeing your doc, I’m unable to diagnose. I might recommend emailing our support team: Support at Coda | Coda Help Center

1 Like

Hi @shushimi! We’re planning for improvements in this area, and would love to hear more about the specific use case you have in mind for this:

My ultimate goal is to : Provide a few buttons. When button A is in “pressed” state, the table will be filtered based on specific value. When button A is “unpressed”, the table will be unfiltered. Same for rest of other buttons.
I hope to achieve this , without involving intermediate widget (such as checkbox or dropdown list)

Are you able to share more about what data is in the table that you’re filtering, and what specific filter conditions you want the button to apply/unapply?

If you’re not able to share in the forum, feel free to send me a private message. Thanks!

2 Likes

Hi @nathan , really glad to hear about such planning in this area. here is my use case.

I wanted to create a cheat sheet on technology related stuff, for easy lookup reference, say unix commands lookup cheatsheet
So my use case is to create a table where there are typically 3 columns: Description, Command and Tag. E.g Description-- check current working directory. Command – pwd. Tag – view information
I could have hundreds of different commands in the table, hence hundreds of rows. So the plan is to have several buttons, each when pressed will cause the table to display only records with specific tag. E.g Pressing on a button will display only those records whose tag is “view information”. If i press down 2 buttons (say, button A filter “view information”, and button B filter “file modification”), then only those records whose tags are “view information” and “file modification” will be displayed.
If i now unpress the “view information” button, then obviously, the table will now display only “file modification”.

Of course, i might be able to achieve the above with formulas, but i forsee the formulas would be complex , especially with more buttons, and i also hope to achieve the above easily , and without going thru any intermediate interactive filter. One way is to allow us to configure table filter directly in the buttons, which to me, is sometime more intuitive than to set the filter in the table itself.

Side note: It might not be apply to button alone, other elements such as toggle apply the same.

1 Like