Grouping layers in JavaScript Basic Viewer's Table of Contents template on

Discussion created by kmacleod on Jan 3, 2013
Latest reply on Jul 31, 2013 by amandevi
Hi all, I searched and didn't see this question or anything like it. Apologies if this is a redundant post!

I am creating a javascript site, currently based off of and the JS Sample Basic Viewer template.

We are converting a Flex site to Javascript. I'm new at this. One nice thing I noticed about the Flex site is it groups REST layers together, as they are organized on the server. It creates a hierarchical folder tree and you can EITHER click a group to turn all sublayers on, or you can expand it with an arrow and the list drops down, where you can turn on one or more layers.

In this way it is "smart". When I add them to if I point to the group of layers they all draw at once. Actually, on the website it also does exhibit this behavior. However, it does not do this on the locally hosted viewer when I browse to it on as it???s stored on my machine (when it loads our copy hosted here, and ???played??? in Visual Studio) doesn't expand to allow turning individual layers off. When I add them each individually, they all appear in my Table of Contents widget in the JS Viewer, making quite a long list of layers. 

Is there a way to make the Sample Viewer layer list widget behave as the Flex one does, on our locally-hosted site based on the JS Basic Viewer, out of the box? Or if not, has someone already created custom code to do this or is there a straightforward way to achieve this?

Thanks all.