Use Check Boxes to Hide Columns in Tables

Hey Guys,

How would I go about using Check Boxes to hide and un-hide columns in a table?

Hi DB2,

Happy New Year!

You’ll have to be running FPMI v3.3.0 for this solution to work. This version introduced a new Column Attributes dataset for tables. I first made sure there was data in the dataset by opening the Table Customizer and checking one of the column Hide boxes. I then put a checkbox on the screen with the following code in its actionPerformed event:table = event.source.parent.getComponent('Table') checkboxValue = event.source.selected table.columnAttributesData = fpmi.dataset.setValue(table.columnAttributesData,0,"hidden",checkboxValue)Just change the number to match the column you want the checkbox to affect (remembering it is zero for the first column). This code will hide the column when the checkbox is ticked.

Al

Works great,

Is there a way to determine the column location, for some reason the locations didn’t run left to right starting with 0. It also seems to limit you to 20 columns, my current table had 23 columns and if I tried to use column number 21 or larger I would get an error saying column number 2 not valid.

How many rows does the columnAttributesData dataset have?

FYI - We spoke over the phone - this was due to a bug that is fixed for 3.3.1.

Sorry to bring this back up, but is there a way to determine column location. I have the listing of columns that I want to hide in a list. I want to loop through that list and turn off the columns in my table that I don’t have any values in.

The columns are defined in the columnAttributes dataset, so you can loop through that. But the reporting component’s ColumnSelector components sounds like a better (no scripting) solution for what you’re trying to do.

Thanks Carl. I actually used both solutions. I looped through to only display columns in the table that have data in them and give the use the option to select columns to display and or output to their report using the reporting component’s ColumnSelector. The end users seem happy with this solution.
Thanks!!