Layer in Layer List Widget - Enable/Disable

354
3
03-24-2020 04:06 AM
KafilBaig
New Contributor III

Can we disable or enable layers in Layer list widget programmatically. I have a RestAPI where permissions are checked and based on that i need to disable or enable layers in Layer List Widget. 

I tried adding below code in showLayers function but it dint work.

this.config.layerOptions["roads_5062"].display = false

Is there any other place i need to set this, Please guide me on this.

Thanks in Advance.

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Kafil,

   Here is how to hide certain layer in the LayerList widget:

https://community.esri.com/thread/228186-layerlist-widget-programatically-filter-layers 

0 Kudos
KafilBaig
New Contributor III

Hi Robert,

I tried to implement this code but no result. Please let me know where exactly I need to place this code to work .

I don’t want to click the button of layer widget. It should automatically disable on startup .

Sent from my iPhone

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Kafil,

   I do have exact directions for your workflow. I have provided a link to a method that use a button click, but that same code can be used when the widget starts based on your requirements.

0 Kudos