I have a widget that is adapted from the Addlayer widget (AddLayer Widget by softwhere). The widget has two items - the top is a dijit.form.Select and bottom is a listview(see attached picture). When a box is checked, a layer is loaded to a map. What I would like to implement is - once a new item is selected from the select dropdown list, certain layers in the layer list are checked, which triggers the onLayerSelected event, so that the map services associated with those layers are loaded to the map. I write an onSelectChange event, which get the related checkbox, and set its checked to be true. Codes are running fine, but the box is not checked and the onLayerSelected is not triggered. Do I miss anything? Thanks so much.
Helen
widget,html-
<div>
<!--<div class="help-text">Check the additional layers to add to the map</div>-->
<div>
<input type="select" data-dojo-type="dijit/form/Select" data-dojo-props="name:'theme',style:'width:100%;'"
data-dojo-attach-point="themeDijit" data-dojo-attach-event="Change:onSelectChange" />
</div>
<div class="layer-list-body" data-dojo-attach-point="layerListBody">
<!-- layer list table added here-->
</div>
<hr />
<div data-dojo-attach-point="message"></div>
</div>
widget.js -
onSelectChange: function (newValue) {
var fields = newValue.split(',');
array.forEach(this.config.layers, function (layer) {
if (layer.name === "Fire") {
var cb = registry.byId("Fire"); //checkbozx is found
cb.set("checked", true); //checked property is set. But the check box is not checked in the widget
//and onLayerSelected is not fired?
}
}, this);
},
onLayerSelected: function (evt) {
var layer = evt.layer;
this.addLayerToMap(layer);
},