How to manually refresh the layerList after creation

01-21-2020 04:02 PM
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
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
New Contributor II

Hi Kristian,

Here Is a code example. 

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.