kmacleod

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 - http://forums.arcgis.com/threads/32804-AGS-JavaScript-Api-Combined-TOC-Legend-Contol        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 = this.data.visible;
    // if it is a group layer and no child layer is visible, then collapse
    
    if (this.data._subLayerInfos) {
      var noneVisible = true;
      dojo.every(this.data._subLayerInfos, function(info) {
        if (info.visible) {
          noneVisible = false;
          return false;
        }
        return true;
      });
      if (noneVisible) 
        show = false;
    }
    
    if (this.data.collapsed) 
      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) 
      dojo.style(this.containerNode, 'display', show ? 'block' : 'none');
    
    if (this.rootLayerTOC.toc.style == 'standard' && this.iconNode && this.checkNode) {
      dojo.place(this.iconNode, this.checkNode.domNode || this.checkNode, 'before');
    }

Outcomes