Collapse layers group when starting the app

202
6
02-21-2020 07:32 AM
ErfanGoharian
New Contributor III

I managed to have a grouped layers list, however, the problem I have is that when I use the "openAll" option (not the drop-down option), and because I have so many groups, when I start the app it shows all the groups open (first figure). I can collapse them manually (figure 2), but I am trying to find out how can I have just one expanded when I start the app?

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor
ErfanGoharian
New Contributor III

Thanks, Robert Scheitlin, GISP. I exactly did what you said, and also checked these codes as well (https://community.esri.com/thread/237493-is-it-possible-to-collapse-multiple-layer-lists-by-default ). I still get strange results, where the titles of all my sub-groups are gone!

Here is also part of mu Config.json code:

 

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Erfan,

   So it looks like you are having the issue that has been addressed in the second threads code. The important part is the setTimeout in the code below (line 24):

      createFoldableBtn: function() {
this.foldableNode = html.create('div', {
'class': 'foldable-btn',
'role': 'button',
'aria-label': this.headerNls.foldWindow,
'tabindex': 0
}, this.btnsContainer);

this.own(on(this.foldableNode, 'click', lang.hitch(this, function(evt){
evt.stopPropagation();
this.onFoldableNodeClick();
})));

this.own(on(this.foldableNode, 'keydown', lang.hitch(this, function(evt) {
if(evt.keyCode === keys.ENTER || evt.keyCode === keys.SPACE){
evt.stopPropagation();
this.onFoldableNodeClick();
}else if(evt.keyCode === keys.TAB && evt.shiftKey){
evt.preventDefault();
}
})));

if(this.openfolded){
setTimeout(lang.hitch(this, function(){
this.onFoldableNodeClick();
}), 500);
}
},
0 Kudos
ErfanGoharian
New Contributor III

I exactly have the same code there:

Still, I am getting the strange behavior from this though!

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Sorry I am not sure then.

0 Kudos
ErfanGoharian
New Contributor III

When I start the app it seems it wants to load it as I want (we expect), but suddenly it goes wrong:((

0 Kudos