Query Widget Result Item Contents

11747
33
Jump to solution
03-25-2015 10:53 AM
TonyGroeneveld
New Contributor III

For the Query widget you can define which fields, alias, special type and order of  the results.  I have had no luck making these changes work or stick.

For example if you change the alias, special type or order of the result item contents and click ok.  None of the changes are saved.

0 Kudos
33 Replies
MaryAnnSteinmetz
New Contributor III

Thank you! That did it.

0 Kudos
NicholasBarger
Occasional Contributor III

Here is some code that you might find helpful.  Robert Scheitlin helped me with this section.  Alows me to sort the Query Results by a specific field.  I nested the If statements to capture all of the different queries.  This selects them based on the ID of the service.  Add the bold section of code to the existing section for _queryByObjectIds

_queryByObjectIds: function(objectIds, returnGeometry){

        var queryParams = new EsriQuery();

        queryParams.returnGeometry = !!returnGeometry;

        queryParams.outSpatialReference = this.map.spatialReference;

        queryParams.outFields = this._getOutputFields();

        queryParams.objectIds = objectIds;

       var layerId = this._getLayerIndexByLayerUrl(this.currentAttrs.config.url);

        if (layerId === 18){

          queryParams.orderByFields = ["NAME"];

        }

        var queryTask = new QueryTask(this.currentAttrs.config.url);

        return queryTask.execute(queryParams);

      },

0 Kudos
MaryAnnSteinmetz
New Contributor III

Nicholas,

Thank you but Robert pointed me to the ArcGIS Online Assistant where I was able to edit the JSON and save the change there.

It’s working now.

MaryAnn

0 Kudos
NicholasBarger
Occasional Contributor III

I'm not sure.  I found it fairly annoying but simple to add this code into the Query widget.js code...

var layerId = this._getLayerIndexByLayerUrl(this.currentAttrs.config.url);

        if (layerId === 17){

          queryParams.orderByFields = ["STATION"];

        }

        else

        if (layerId === 18){

          queryParams.orderByFields = ["DEPARTMENT"];

        }

Just match up the layerid with the correct field name of the service.

KirkHarstead
New Contributor III

Nicholas,

Do you know if the orderByFields parameter can be changed using the ArcGIS Online Assistant site? I've used this to change the json file for things like setting the special type and adding links to the upper banner. But I can't seem to find any information on the orderByFields parameter in the json through the Online Assistant. I would really like to change the order of the results window after a query is run, so any help on this issue would be much appreciated! Thank you.

0 Kudos
LeaDyrholm_Hansen
New Contributor III

By the way these three bugs are now registered at Esri Support - so hopefully they'll soon be fixed 🙂

BUG-000086536 : Query Widget in the ArcGIS Online Web AppBuilder does not respect changes made to the Alias when configuring the Results Setting in the query

BUG-000085190: The contents of the Results Ordering tab in the query widget editor window resets to the default order, after closing and reopening the query editor in Web AppBuilder.

BUG-000085839: Query Widget in the ArcGIS Online Web AppBuilder does not maintain Special Type when configuring the Results Setting in the query.

StanMcShinsky
Occasional Contributor III

Lea Dyrholm Hansen

Thanks for sharing the BUG #s. It is nice to see this active response from ESRI to help out instead of feeling like our questions and comments get lost in the wind.

-Stan

KevinHatch
New Contributor III

I am experiencing a strange error.  On one map I run a query but I receive a Query Failed error if the results exceed a couple of hundred results . But on a second map (using the same instance of WAB Developer) I can run exactly the same query without receiving the error.

Is there a map setting I am missing that defines the total number of results?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kevin,

   can check the json file for both of your query widgets and verify that they are configured identically?

KevinHatch
New Contributor III

I thought that initially.  But I duplicated the template, switched the web map, and rebuilt the queries and the same issue has occurred. I even used AGOL and the issue occurs there. 

It is very weird:

1) If I add the web map layer directly from Map A it works just fine (query over 8000 records and they all appear) (TRUE FOR MAP A ONLY)

2) If I add the same layer above using a service URL it limits the results to ~250 records (TRUE FOR ALL MAPS)

3) If I add the exact same layer but using a different web map it limits the record size to ~250 records (TRUE FOR MAP B ONLY)

4) If I add a public layer from ARC GIS Online it works fine (TRUE FOR ALL MAPS)

The above is true for ALL tested layers.  It isn't isolated to a single layer. 

I have compared the layer info from the two web maps.  They appear to be identical.

1) Linking to a service URL (rather then adding directly via map) on our server causes the results to be limited to ~250

2) The results off all layers in Web Map B are limited to ~250.

0 Kudos