Modify Select Widget WAB

3650
13
Jump to solution
08-08-2016 11:17 AM
JoelEdgar
New Contributor II

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.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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
        });

View solution in original post

13 Replies
RobertScheitlin__GISP
MVP Emeritus

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
        });
helenchu
Occasional Contributor II

Robert,

I need 1 layer checked by default.  How do I do it ?

Thanks

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

helenchu
Occasional Contributor II

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
});

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

helenchu
Occasional Contributor II

I got it.  Thank you very much!

0 Kudos
GeorgeKatsambas
Occasional Contributor III

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I have not seen that one.

GeorgeKatsambas
Occasional Contributor III

Anybody know why when I use the select widget in the fold-able theme wab 2.5 the selection does not show now?

0 Kudos