Select to view content in your preferred language

Hide ObjectID in WAB Query Result

1302
3
Jump to solution
11-14-2016 04:11 PM
LesiMai3
Deactivated User

Hi all,

I was wondering if there is a way to keep ObjectID from displaying when users view the query results in the attribute table.

Any pointers will be greatly appreciated!

Lesi

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lesi,

  In the Query Widget Widget.js make this change to the _showResultLayerInfo (line 17 - 21):

      _showResultLayerInfo: function(resultLayerInfo){
        this._hideAllSingleQueryResultDijits();
        var singleQueryResult = resultLayerInfo.singleQueryResult;
        var resutlLayer = null;
        if (singleQueryResult) {
          html.setStyle(singleQueryResult.domNode, 'display', 'block');
          var currentAttrs = singleQueryResult.getCurrentAttrs();
          resutlLayer = lang.getObject("query.resultLayer", false, currentAttrs);
        }

        if (resutlLayer) {
          this._activeLayerId = resutlLayer.id;
          this._hideAllLayers(resutlLayer);
          resutlLayer.show();
          //now show in at widget
          var layerInfo = this.layerInfosObj.getLayerInfoById(resutlLayer.id);
          array.map(layerInfo.layerObject.fields, function(fld){
            if(fld.name === layerInfo.layerObject.objectIdField){
              fld.show = false;
            }
          });
          this.publishData({
            'target': 'AttributeTable',
            'layer': layerInfo
          });
        }else{
          this._activeLayerId = null;
          this._hideAllLayers();
        }
      },

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Lesi,

  In the Query Widget Widget.js make this change to the _showResultLayerInfo (line 17 - 21):

      _showResultLayerInfo: function(resultLayerInfo){
        this._hideAllSingleQueryResultDijits();
        var singleQueryResult = resultLayerInfo.singleQueryResult;
        var resutlLayer = null;
        if (singleQueryResult) {
          html.setStyle(singleQueryResult.domNode, 'display', 'block');
          var currentAttrs = singleQueryResult.getCurrentAttrs();
          resutlLayer = lang.getObject("query.resultLayer", false, currentAttrs);
        }

        if (resutlLayer) {
          this._activeLayerId = resutlLayer.id;
          this._hideAllLayers(resutlLayer);
          resutlLayer.show();
          //now show in at widget
          var layerInfo = this.layerInfosObj.getLayerInfoById(resutlLayer.id);
          array.map(layerInfo.layerObject.fields, function(fld){
            if(fld.name === layerInfo.layerObject.objectIdField){
              fld.show = false;
            }
          });
          this.publishData({
            'target': 'AttributeTable',
            'layer': layerInfo
          });
        }else{
          this._activeLayerId = null;
          this._hideAllLayers();
        }
      },
LesiMai3
Deactivated User

Thank you, Robert!

0 Kudos
GilbertoMatos
Frequent Contributor

Hello @RobertScheitlin__GISP ! How are you?

I have an application that was developed with web appbuilder 2.2, and I need the objectid fields not to appear in the layer tabs inside the attribute table widget. I checked your code given as a solution, however in the application I need to work on, the "Query" widget does not exist in the list of widgets used in the application. I've tried to debug and change the code inside the attribute table widget.js, but unfortunately I was not successful. Do you have any other suggestions for me?

Thanks in advance for your help.

 

Gilberto.

0 Kudos