Select to view content in your preferred language

Layer List: Expand Layers by Default

19446
60
Jump to solution
06-18-2015 04:26 PM
AdamAraza1
Deactivated User

I thought I had posted this on here already, but I can't seem to find it....

I'm using the tab theme and I have the layer list opening by default in the side panel. Is there a way to have it open with all the layers already expanded showing the symbology without having to click on each individual layer?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

All,

  If you don't mind the possible performance impact then the workaround is to open the LayerListView.js and find the layerTitleNode click event (@ line 205) and add these lines after it @ line 213

If you want to change this for all apps you produce in the future then change this file: client\stemapp\widgets\LayerList\LayerListView.js

If you want to change on specific app then change this file:server\apps\APP##\widgets\LayerList\LayerListView.js

      setTimeout(lang.hitch(this,
                           this._onRowTrClick,
                           layerInfo,
                           imageShowLegendNode,
                           layerTrNode,
                           tableNode), 300);

View solution in original post

60 Replies
JunshanLiu
Frequent Contributor

Expand all layers when opening the layer list widget will have performance issue, because open layer may cause a HTTP request.

PatKeegan
Frequent Contributor

I acknowledge the performance issue, but I am also looking to have layer list expanded by default. In my usability testing people have not understood they must expand the tree to control layers. Most of our maps have just one closed node in layer list at startup.

Any advice on how to override the default behavior appreciated....even if there is a performance hit.

0 Kudos
ChadTinsley
Emerging Contributor

The layer list will open by default if each layer is added on it's own rather than adding the entire mapserver or featureserver service as a group layer. That's the work around I've always used for this problem.

For example rather than adding blabla/arcgis/rest/services/folder/servicename/MapServer to add all of my layers I add them one at a time

blabla/arcgis/rest/services/folder/servicename/MapServer/0

blabla/arcgis/rest/services/folder/servicename/MapServer/1

blabla/arcgis/rest/services/folder/servicename/MapServer/2

etc.

RobertScheitlin__GISP
MVP Emeritus

All,

   I should have a workaround for you tomorrow.

RobertScheitlin__GISP
MVP Emeritus

All,

  If you don't mind the possible performance impact then the workaround is to open the LayerListView.js and find the layerTitleNode click event (@ line 205) and add these lines after it @ line 213

If you want to change this for all apps you produce in the future then change this file: client\stemapp\widgets\LayerList\LayerListView.js

If you want to change on specific app then change this file:server\apps\APP##\widgets\LayerList\LayerListView.js

      setTimeout(lang.hitch(this,
                           this._onRowTrClick,
                           layerInfo,
                           imageShowLegendNode,
                           layerTrNode,
                           tableNode), 300);
MichaelPotter1
Regular Contributor

Is there any way to modify this solutions to only expand the Map Service, not the legend part?

I would like my users to see what layers are in the Map Services without them needing to expand the layer but I do not want the legend for each layer to be expanded.

I am aware of the possibility to add each individual layer from my Map Services but this is not preferred as I would still like to keep things grouped by each Map Service.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Michael,

  Sure just use this block of code instead:

      if(layerInfo.newSubLayers.length > 0){
        setTimeout(lang.hitch(this,
                   this._onRowTrClick,
                   layerInfo,
                   imageShowLegendNode,
                   layerTrNode,
                   tableNode), 300);
      }
MichaelPotter1
Regular Contributor

Works like a charm, thanks for you help Robert.

It is greatly appreciated.

Regards

0 Kudos
DanielChantlos1
Regular Contributor

Robert,

I'm trying this right now in LaunchPad theme. When I enter in the codeblock, everything on my Layer List widget disappears. I've attached a screenshot showing the code I'm using. Does this look correct?ExpandLayerList_Default.PNG

0 Kudos