Why isn't "returnDistinctValues" an option for the "Query" object in the JS API?

3108
5
10-29-2013 07:47 AM
BrianBeck
New Contributor III
I was just looking over the Esri JS API documentation and the Esri REST API documentation at query operations.  I noticed that the query REST endpoint is called by the FeatureLayer.queryFeatures function.  The query REST endpoint has an option for returnDistinctValues to get a list of unique values in a field.  Why isn't this an option for the Query object in the JS API.  It's always a lot of trouble to have to sift through the results of a query to get the unique values and it's even worse when there are more values than are returned by a single query.
0 Kudos
5 Replies
JohnGravois
Frequent Contributor
that particular query parameter has not yet been added to our JavaScript API.

[NIM091580: Add 'returnDistinctValues' property to the esri.tasks.Query class.]

until it is included, you might consider using esriRequset.setRequestPreCallback() to catch the request immediately before it is issued and modify it as needed.
0 Kudos
Drew
by
Occasional Contributor III
I was just looking over the Esri JS API documentation and the Esri REST API documentation at query operations.  I noticed that the query REST endpoint is called by the FeatureLayer.queryFeatures function.  The query REST endpoint has an option for returnDistinctValues to get a list of unique values in a field.  Why isn't this an option for the Query object in the JS API.  It's always a lot of trouble to have to sift through the results of a query to get the unique values and it's even worse when there are more values than are returned by a single query.


Maybe I am missing something, but  in 3.8 its still not in there...
I was able to work around it by adding the REST parameter in myself..

Sample
var queryTask = new QueryTask(dataURL + "?returnDistinctValues=true"); 


Drew
JasonHine
Esri Contributor

Kudos to John and Andrew for the workarounds. A few follow-up notes:

  • Appending the parameter directly to the QueryTask URL probably means that parameter is set for the life of the QueryTask.  If you want to be able to set the parameter on a query-by-query basis, use John's workaround (esriRequset.setRequestPreCallback()​).
  • The workarounds given in this thread should also work for other Query properties, such as returnM and returnZ.  The lack of these properties on Query is noted in NIM091578.
0 Kudos
AlexandreLuquetta
New Contributor
Very thanks cgishack!

It´s worked!
0 Kudos
PremRadhakrishnan
New Contributor III
that particular query parameter has not yet been added to our JavaScript API.

[NIM091580: Add 'returnDistinctValues' property to the esri.tasks.Query class.]

until it is included, you might consider using esriRequset.setRequestPreCallback() to catch the request immediately before it is issued and modify it as needed.


As of 3.9 This is still not in the JS API, the workaround does work it would be cleaner for it to be part of the API. The reported BUG number NIM091580 cannot be found inthe bug base either.
0 Kudos