How to manually refresh the layerList after creation

297
2
01-21-2020 04:02 PM
NickStapler
New Contributor II

I am adding/removing layers nested within group layers. These modifications do not seem to always cause a refresh/ trigger the listItemCreatedFunction to rerun. I need the listItemCreatedFunction to run everytime i add/remove layers from the map/nested groups.

How can I force a refresh of the layerlist? I have noticed that the layerlist triggers listItemCreatedFunction at initial creation and also when using sketchviewmodel.complete().

I've considered creating a new layerlist and replacing the existing list, but that seems like a resource intensive option.

Any suggestions?

0 Kudos
2 Replies
KristianEkenes
Esri Regular Contributor

Hey Nick. Can you post a code pen or some other live app that demonstrates this issue? You shouldn't have to refresh the LayerList yourself. If the updates aren't getting picked up, then it could be a bug.

0 Kudos
NickStapler
New Contributor II

Hi Kristian,

Here Is a code example.

https://codepen.io/greenGoose45/pen/WNbPvNL 

To simulate the error, press the "addlayer to group button" once the map has loaded and look for the added layer within the innermost grouplayer. The legend is not generated for these layer and if you put a breakpoint in the console, the listItemCreatedFunction does not trigger.

I'm also attaching the html file if that works better.

Best,

Nick