So I found the Query Widget to be useful, well about 75% useful. So, while the widget functions correctly and works well the results are unable to be sorted. This makes it difficult identifying the result that I want. The main problem that I see with this is that it uses the objectID to sort the results (confirmed by esri tech support).
Thankfully they got me on the right track in coding the tool to be sorted. We found that this code queryParams.orderByFields = ["FIELD_NAME"];
placed after line 828 directly following this code, queryParams.objectIds = objectIds; correctly sorted my first query in the widget. However it failed when a second was added.
The tech supports advice was to add an if statements using the url / ID to differentiate the queries and sort each one accordingly. So I found the following code around line 416 - 419 that parsed out the id number from the url.
var lastIndex = layerUrl.lastIndexOf("/");
var a = layerUrl.slice(lastIndex + 1, layerUrl.length);
return parseInt(a, 10);
I used the variable parseInt in an if statement (below) and it correctly sorted the corresponding search, but failed on the others (obviously), and also killed all of the click functions.
if (parseInt = 18)
queryParams.orderByFields = ["NAME"];
As I see it now I have 2 options...
- Correct the if statement to work correctly...but what am I missing?
- Build multiple queries into a group widget... I think this is possible right?
I don't like option 2 as much even though, if possible, it would be easiest. I would be able to hard code the sort field per query and all would be good. However, the current Query widget lends itself well to having multiple queries in the single widget.