Currently when I open the select widget in web appbuilder the features currently set for selection match the layers I have check on in my layer list. I would like to modify the select widget code so that all the layers are unchecked by default and not tied to items checked on/off in the layer list.
Solved! Go to Solution.
Joel,
If you are using WAB Dev edition then you can edit the select Widget.js in the _initLayers function (line 13):
_initLayers: function(layerInfoArray) {
this.layerInfoArray = layerInfoArray;
this.layerItems = [];
this.selectionSymbols = {};
html.empty(this.layerItemsNode);
array.forEach(layerInfoArray, lang.hitch(this, function(layerInfo) {
var visible = layerInfo.isShowInMap() && layerInfo.isInScale();
var item = new SelectableLayerItem({
layerInfo: layerInfo,
checked: false,
layerVisible: visible,
folderUrl: this.folderUrl,
allowExport: this.config ? this.config.allowExport : false,
map: this.map,
nls: this.nls
});
Joel,
If you are using WAB Dev edition then you can edit the select Widget.js in the _initLayers function (line 13):
_initLayers: function(layerInfoArray) {
this.layerInfoArray = layerInfoArray;
this.layerItems = [];
this.selectionSymbols = {};
html.empty(this.layerItemsNode);
array.forEach(layerInfoArray, lang.hitch(this, function(layerInfo) {
var visible = layerInfo.isShowInMap() && layerInfo.isInScale();
var item = new SelectableLayerItem({
layerInfo: layerInfo,
checked: false,
layerVisible: visible,
folderUrl: this.folderUrl,
allowExport: this.config ? this.config.allowExport : false,
map: this.map,
nls: this.nls
});
Robert,
I need 1 layer checked by default. How do I do it ?
Thanks
Helen,
Check the layerInfo to see if it is the layer that you need and if so don't change the SelectableLayerItem checked to false.
Hi Robert,
I just tried this line of code to see how it's like and already it gives me error : "Expected identifier or string".
Could you please tell me what is wrong with my codes ?
Much appreciated!
_initLayers: function(layerInfoArray) {
this.layerInfoArray = layerInfoArray;
this.layerItems = [];
this.selectionSymbols = {};
html.empty(this.layerItemsNode);
array.forEach(layerInfoArray, lang.hitch(this, function(layerInfo) {
var visible = layerInfo.isShowInMap() && layerInfo.isInScale();
var item = new SelectableLayerItem({
layerInfo: layerInfo,
if (item.layerName ==='Accounts'){
checked: visible;
}
else {
checked: false;
}
layerVisible: visible,
folderUrl: this.folderUrl,
allowExport: this.config ? this.config.allowExport : false,
map: this.map,
nls: this.nls
});
Helen,
You should not have an if statement inside a objects constructor like you do now. You need to do your if statement before the constructor for the layer selection object.
I got it. Thank you very much!
I have a WAB map. when the mapservice is not symbolized by a value the select widget shows the selection
when a map service is symbolized by a value the selection does not show. Is this a bug? The popup shows that I have a selection.
I have not seen that one.
Anybody know why when I use the select widget in the fold-able theme wab 2.5 the selection does not show now?