Layer List Widget (Beta) Button and Drop Down Menu Button not working

3581
5
08-19-2015 12:30 PM
SimonFisher
Occasional Contributor II

I know the Layer List Widget is still in Beta at v3.14, but I have been trying to add a Button (dijit.form.Button), or even better would be a Drop Down Menu Button (dijit.DropDownMenu) to the Layer List Widget via the button property.  I can add the button and it shows up fine, but the click event is not firing, so the button is useless.  I have tried using both a button and drop down menu button and tried using the LayerList button and content properties and both result in the same; the buttons show but do not work or fire the events.  It almost seems like the events are blocked.  It also seems like the button and content properties only support showing the parent node, no child nodes seem to display, so this could be related.

Has anyone successfully implemented buttons on the Layer List Widget?  and if so how?

Thanks

Simon

0 Kudos
5 Replies
KenBuja
MVP Honored Contributor

This example shows both the button and a slider that have been attached to the LayerList and have been wired to do something

JS Bin - Collaborative JavaScript Debugging

SimonFisher
Occasional Contributor II

Thanks Ken,

My scenario is a bit different as I am dynamically creating the layers for the layer list and thus dynamically creating the buttons programmatically in JavaScript not declaratively like your example.  But your example does prove that the button property does work, so thanks for sharing.  I have been able to add the sliders to the content property programmatically and added drop down menu buttons to the button property declaratively.  Just not able to add the drop down buttons programmatically yet, they show but don't work, but it could be something I'm missing in my own code.

Thanks again for sharing,

Simon

0 Kudos
KenBuja
MVP Honored Contributor

Can you share your code or create an example of what you're doing?

0 Kudos
SimonFisher
Occasional Contributor II

Hi Ken,

Sorry for the delay here as I have been on vacation for a few weeks.

I was able to figure this out, it seems I have to do my dynamic creation of the button and popup menus and add to the layer List after the Layer List is loaded.  If I do this prior to the Layer List load and pass in the UI gets messed up.

Thanks for pointing me in the right direction!

Simon

0 Kudos
YiQi2
by
New Contributor

Dear Simon:

I am also trying to program a dropdown menu or radio button to toggle my layers. My problem with the default Layer List Widget is that I don't want users to open two layers at the same time due to poor map overlaying. The dropdown menu or radio button would limit users' access to only one layer at a time. Can you share some your code so I can learn from your wisdom?

Thanks,

Yi

0 Kudos