Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Adding Columns that are hidden

Issue

I am trying to add a button to a table in my app, where users can select which columns they want to see. However, the button is not working and I am not sure how to make it show the selected columns. Additionally, I want the columns to be hidden by default and only shown when the user clicks the button, but this doesn't seem to be working either. I am looking for a solution to make this feature work in my app.

Resolution

To add a button that allows users to show or hide selected columns in a table, you can use the storeValue() function in the onClick event of the button to save a boolean value in Appsmith store. Then, use this value in the Visible property of the column to show or hide it programmatically. If you want to have the columns hidden by default and only shown when the user clicks the button, you can set the Visible property to {{true}} or {{false}} depending on the value in the Appsmith store.

You can also use a Multiselect widget instead of a button to allow users to select which columns to show or hide. In this case, you would only show the columns whose names are within the selected options.

Example code for the button solution:



  1. Add a Button widget to your page.

  2. In the onClick event of the button, enter {{storeValue('showColumn', true)}} to save the value true in the Appsmith store.

  3. In the Visible property of the column you want to show/hide, enter {{true}} if you want it to be shown by default or {{showColumn}} if you want it to be shown based on the value in the Appsmith store.

Example code for the Multiselect solution:



  1. Add a Multiselect widget to your page.

  2. Set the options of the Multiselect to the names of the columns you want to show/hide.

  3. In the Visible property of each column, enter {{options.selected.includes(columnName)}} where options is the name of the Multiselect widget and columnName is the name of the column. This will show the column only if its name is in the selected options of the Multiselect.