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

3524
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
DougBrowning
MVP Frequent Contributor

Did you ever get anywhere on this?

0 Kudos
C_EHoward
Occasional Contributor III

Not at all. I had to abandon the idea and only use datasets where I could hard code my values into a value list for a parameter. If the query widget had the filter ability (like the 3rd party tool) I could at least use that to generate my lists as another less-than-ideal solution but still no dice.

I was hoping someone at least would have commented that this is easy/way hard/etc but I guess no one else out there thinks being able to use the same validation tools/choice lists/etc in desktop is important in WAB

I've logged enhancement requests for similar functionality so maybe they will go somewhere

0 Kudos
RickeyFight
MVP Regular Contributor

So what you want can be done I believe,

Look here:

GitHub - daFiter/localLayer_filter: Esri Web AppBuilder filter Widget

This is for an old form of WAB but you should be able to def query in the drop down idea you want.

0 Kudos
C_EHoward
Occasional Contributor III

Thanks for the link, I certainly did not see this. I will examine more closely tomorrow, but it still looks to me that you have to define your list (the first step defining the option values). I have lots of unique values so I am trying to avoid defining them. BUt this may be promising if I can devote time to developing (I am dev lite, heavy on the lite )

thanks again--

0 Kudos
DougBrowning
MVP Frequent Contributor

Yea still looks like manual list.  I just want a drop down as input that is tied to a Feature service into my geoprocessing service really.

0 Kudos
RickeyFight
MVP Regular Contributor

Yes, sorry this is a manual list.

I never worked out a way to make it dynamic.

0 Kudos
DianeWhited
New Contributor

Has anyone figured out how to have WAB dynamically populate the list of fields from a feature class selected in a GP widget?  The choice list is always hard coded when upload my GP service.  Is there something I am missing in the parameter definitions?

Thanks in advance.

Diane

0 Kudos
C_EHoward
Occasional Contributor III

No idea- I have yet to get anything to work with WAB and populated lists from a GP service. The query widger seems like the logical place for this functionality to live, but since the filters do not populate lists based on your first choice, its useless to me. Hope someone figures this out-

0 Kudos
IfeomaCollins
New Contributor II

Hi Diane,

I have figured out a way to have a dynamic parameters (whether it's a drop down or multi select widget) based on a selected value from another parameter in my WAB gp widget. 

My suggested workflow:

1). On your GP widget UI, find the widget ID of the parameter you want to monitor using dijit.byId or registry.byId.

2). Create an event handler to watch for changes in value to this editor and capture the value it was changed to

3). Write the code to create the variables with your desired dynamic values based on what was selected in step 1 using if/then statements, getting results from a GP service, or whatever logic you need, etc 

4). Find the widget ID of the parameter that needs to be dynamically changed based on the value selected in step 1.

5). Use registry.byId's set/reset method to update the values of the widget in step 4 dynamically with the variables you created. 

Note: you may have to use dojo/ready and dojo/connect to make sure your widget is fully loaded.

Hope this helps!