Hi,
I am trying to modify the Save Session widget to save changes made by the user in the order of the layers, but I am stuck.
I succeeded in reorder the layers in the map, but the LayerList still shows the previous order.
Is there a simple way to force the LayerList to refresh?
I tried to add and then remove a dummy layer, with the following results:
- if the LayerList is not loaded when I load the session, everything works fine
- if the LayerList is already loaded when I load the session, the LayerList does not refresh
To add and remove the layer I simply used addLayer and removeLayer:
var dumLayer = new ArcGISDynamicMapServiceLayer(layer.url); this.map.addLayer(dumLayer); this.map.removeLayer(dumLayer);
Did I forget something? I also noticed that if I comment the removeLayer line, the LayerList does not refresh.
I also tried to destroy and recreeate the layer, but I don't undesrstand how to use the WidgetManager createWidget method.
Thanks in advance,
Marco
Solved! Go to Solution.
Marco,
Sure get a reference to the LayerList widget and call its _refresh method.
Marco,
Sure get a reference to the LayerList widget and call its _refresh method.
Hi Robert,
thanks for the help, I didn't know that I could directly call the refresh function.
I noticed that I still have to add and remove the dummy layer for the refresh to take effect, but it's not a big deal.
Thanks again,
Marco
How to refresh layerlist in 4.x?
for someone who is looking for a solution in 4.x can use below function to recompile layerlist
Hi imritanshu
Thanks for this, Would you mind sharing how to implement this as a reset button within the layerlist if you have this worked out?
Thanks for the help with this it's really appreciated.
Leon