Barb, and others who would like use groups/headings,
I want this functionality as well, and there is a way to do this without adding the functionality to the actual TOC-component. What I've done is that I've rewritten the widget to use several TOC-components, one for each group, and each TOC-components only include the layers belonging to that code. In the config-file I specify my different groups and which layers that belongs to them and then in the code I create an Accordion in my case with the different TOC-components.
See the attached image to get an idea of what it might look like, (I've also moved everything to the MapSwitcher and the operational layers box).
One big disadvantage is that I have to specify my layers twice, once in the main config file and once in the TOC-widget/MapSwither config file with the exact same name where I also specify the groups.
Unfortunately I won't be able to share my code as it is because I've made a lot of my own customizations and haven't been careful enough to comment all of my changes.
But the principle of using one TOC-compontent including only some specified layers for each group is a way to achieve groups/headings without to much coding.