In the manual interface, you can click on a column group and then hide/unhide all the columns in the group with a single click (or two/three clicks if the hidden state is mixed).
What is some simple JSL that accomplishes this same thing by script?
My attempts to script this all look squirrelly to me.
Here is a script that works. The current restriction is that it acts on the first group found, but that is an easy work around.
Names Default To Here( 1 );
dt = Current Data Table();
groupNames = dt << get column groups names;
group = dt << get column group( groupnames[1] ) << select;
For( i = 1, i <= N Items( group ), i++,
dt:((dt << get selected columns)[i]) << hide( 1 )
);
Another community member may have a way to take the For() loop out of the code, but I was not able to find one.
Here is a script that works. The current restriction is that it acts on the first group found, but that is an easy work around.
Names Default To Here( 1 );
dt = Current Data Table();
groupNames = dt << get column groups names;
group = dt << get column group( groupnames[1] ) << select;
For( i = 1, i <= N Items( group ), i++,
dt:((dt << get selected columns)[i]) << hide( 1 )
);
Another community member may have a way to take the For() loop out of the code, but I was not able to find one.
Here's a complication: some of the columns in my groups derive from a virtual join. So when I perform a <<Get Column Group("groupname") on those particular groups, the list that results looks like this:
group = {:LocalColumnA, Referenced Column("ForeignColumnA", Referenced Column("ForeignColumnB", Reference(Column(:ForeignLinkReferenceColumnA), …}
and the group<<hide(1) action only succeeds on the local columns, not on the foreign (virtually joined) columns.
Yet when I do this in the manual interface, the virtually joined columns respond just fine to a manual Hide/Unhide menu selection. Aaargh.