Any way to have WAB use/access parameter dependent choice lists? Or query/filter from a query?

3889
15
04-19-2016 12:15 PM
C_EHoward
Occasional Contributor III

In the simplest terms I am trying to do a nested query, such as a user can pick a 'state' and then the 'cities' in the selected state would populate as a choice list/unique values. The 'expression set' in the query tool sounds like what I need but its not since it does not update the available choices based on your first condition...sigh...

So I tried to implement this through a model-turned-GP service-GP widget based on a sample from an Esri blog (Generating a choice list from a field | ArcGIS Blog ) and thought this was THE solution.....until I realized that the behind-the-scenes validation does not get passed when used in WAB. Something so simple as having basic 'select by attribute' type functionality' is seemingly impossible in WAB!

I had someone much more knowledgeable than me take a look at the workflow and this is what they came up with conceptually as what needs to happen to get my desired workflow to be possible in WAB-- that outline is below and attached is a text file with a JS API example of what I'd like to be able to do in WAB. 

  1. Open Web AppBuilder (Developer Edition) and load your Geoprocessing Service into a widget.
  2. Download the application and navigate to .\widgets\Geoprocessing
  3. You'll need to edit the Widget.js to implement the parameter dependent choice list.
  4. From what I can tell it appears that WAB queries the geoprocessing service to get the descriptions of the parameters. It then calls the _createInputNodes function to convert the parameters to the the html that is shown within the Input tab of the geoprocessing widget. Below are the steps that would be needed to implement what you're needing.
    1. Determine how to get a hook into the first drop-down. Note: I wasn't able to figure out this portion.
    2. Fetch the value from the first drop-down. The logic for this is available in the _getInputParamValues function.
    3. Use the value from the first drop-down to fetch the values needed for the filter in the second funtion. Note: I have pasted code below to show this workflow using the JS API. This would outline how the drop-down boxes would interact with each other.
    4. Update the choicelist for the input parameters via this.config.inputParams[1].choiceList = // Array from QueryTask
    5. Remove the html used for the second drop-down. The code for this will be related to the _createRemoveInputNode function in the .\Geoprocessing\editors\simpleEditor.js
    6. Add the html for the second drop-down by calling the _createInputNode function in the .\Geoprocessing\widgets\Widget.js

Anyone else have a need to select/query and have accurate choice lists come up? The query tool is very misleading for an average user  when you select a state 'Arizona' and have 'Philadelphia' come up as a choice of city in the state you just selected.

Ideally the native query tool would let you query completely. Or a 'select' tool that has the functionality like ArcMap's 'select by attributes.' I relied heavily on this type of thing in the good old Flex days.....through the kindness of talented non-Esri developers. But I'd really like to have such basic things available in WAB....or at least workarounds like filters and GP services to work and have Esri developers create some more useful widgets. Thanks for any suggestions

15 Replies
C_EHoward
Occasional Contributor III

Thanks for posting this workflow. I know it would help if I was a programmer and could implement your workflow. Now that you have shown it is possible, I hope someone from Esri on the WAB team  (perhaps dlaw-esristaff‌ or one of his colleagues) can take a look and see if this can become core WAB functionality in the AGOL version. Queries (nested) are great in theory but when you cannot filter your second selection based on your first they are pretty useless. 

If not, hopefully someone like rscheitlin‌ will create another awesome widget that can do what we all seem to need. thanks again--

0 Kudos
DianeWhited
New Contributor

Thanks Ifeoma for the steps!  However I have very little experience programming in JS or other web languages.  Could you provide more detail in what files need to altered.  Or is this just too complex for a little tweaking of code.  Anyway - its good to know that it can actually be done.

Thanks again.

Diane

0 Kudos
IfeomaCollins
New Contributor II

Hi Diane,

It shouldn't be too complex to implement at all. I was able to get this functionality to work by adding the code to the widget.js file. I recommend creating your own method in widget.js after all the input params are created in _createInputNode and passing both the input params and their corresponding nodes as an array to the function you create. And you can call this function in the _createInputNodes method. 

0 Kudos
DerekLaw
Community Moderator

Hi CE,

> In the simplest terms I am trying to do a nested query, such as a user can pick a 'state' and then the 'cities' in the selected state would populate as a choice list/unique values. The 'expression set' in the query tool sounds like what I need but its not since it does not update the available choices based on your first condition...

I think the latest Web AppBuilder update in ArcGIS Online will meet this requirement. Please see the blog post,

What’s New in Web AppBuilder for ArcGIS (September 2016) | ArcGIS Blog 

(specifically the section on Filter and Query widgets)

Hope this helps,

DougBrowning
MVP Frequent Contributor

Any chance on using this feature as the input to a GeoProcessing tool?  I would be so happy..

0 Kudos
C_EHoward
Occasional Contributor III

Thanks Derek- I think this widget enhancement will be very useful-- off to read your blog post

0 Kudos