Select to view content in your preferred language

How to show query results in Attribute Table?

1110
2
01-07-2019 05:13 AM
tarunvisvanadula
New Contributor

hi,how can we display the query results in attribute table widget,in web appbuilder

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Tarun,

   You can follow this guide to add a layer to the Attribute table widget:

Send a layer to the Attribute Table widget—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS fo... 

You will have to create a FeatureLayer from the query results using a Feature collection. See this sample:

Feature collection | ArcGIS API for JavaScript 3.27 

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

in the Widget.js for Query Widget, I made some changes to the  _showResultLayerInfo function, and it seems working:

      _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);
          this.publishData({
            'target': 'AttributeTable',
            'layer': layerInfo
          });
        }else{
          this._activeLayerId = null;
          this._hideAllLayers();
        }
      },

Hope it helps.