how to stop AGS JS TOC from Collapsing

Discussion created by kmacleod on Apr 24, 2013
Hi forum,

Has anyone set Nianwei Liu's AGS JS TOC widget to not collapse layer Groups when it is clicked? In other words, I have a dynamic service with around 100 layers. I've grouped these into a few groups which works great with the AGS widget, whcih groups them hierarchically just like ArcMap.

Now I am wondering how to make it NOT automatically roll up the groups when I turn them off. We want them to stay expanded, unless the user clicks the little "+" button. We do however want it to collapse/expand with the "+" as is normal.

(the AGS widget -        etc )

I have tinkered with the TOC.js code and I believe the relevant block of code is below but I have not succeeded. I set a lot of those visible items to true, set both expandos to "open" etc to no avail yet. Anyone else done this or know how?

var show =;
    // if it is a group layer and no child layer is visible, then collapse
    if ( {
      var noneVisible = true;
      dojo.every(, function(info) {
        if (info.visible) {
          noneVisible = false;
          return false;
        return true;
      if (noneVisible) 
        show = false;
    if ( 
      show = false;
    if (this.iconNode && this.iconNode.src == this.blank) {
      dojo.addClass(this.iconNode, 'dijitTreeExpando');
      dojo.addClass(this.iconNode, show ? 'dijitTreeExpandoOpened' : 'dijitTreeExpandoClosed');
    if (this.containerNode), 'display', show ? 'block' : 'none');
    if ( == 'standard' && this.iconNode && this.checkNode) {, this.checkNode.domNode || this.checkNode, 'before');