Perspective Table Variable Column Count & Header Groups

Just want to get some thoughts about something I'm trying to accomplish. I have an idea of how...

I have a dataset that is comprised of 3 rows (sometimes it may only be 1 or 2 rows). Each row will always have 3 columns that never change. Every row will also have a variable number of columns after those first 3. It will vary between an additional 9 to a max of 36 (in buckets of 9 columns). Those "buckets" of 9 columns should be grouped together with a column header.

Simple Excel example:

When the data is retrieved is when the total number of columns is determined - so I get the entire dataset with the first binding which is a view param. Each SubCol in the groups should be identically formatted with their counterparts in another group. So SubCol3-Group 1 matches the format of SubCol3-Group 2.

As an UI item - I plan on having a button to "collapse/expand" the SubCols to only show 1-2 of the most important ones and hiding the other 7-8. So fits better on a screen without scroll bars but if the end user wishes to see all the data then they can expand it out.

The way I'm thinking of accomplishing this is to do a script transformation on the data property of the table. In that script it would build out a config dictionary for any required column and set it to the columns property of the table. Same would need to happen for the headerGroups property and the data itself (remove unneeded columns to reduce footprint).

Other thoughts, I just had, was to use embedded views - either a flex repeater or using the display property to hide a view when not needed. Each "group" would be it's own flex view with a table. The columns to auto-hide would have their "visible" property bound to a button. <-- changing my direction to do it this way. The other way seems a bit obnoxious with having to rebuild the columns and header groups iteratively.

Thanks for listening! Let me know if you have any other ideas!