Select to view content in your preferred language

Is there any way I can specify programmatically the options that the dropdown must show in the FILTER Widget?

1004
2
06-05-2019 05:34 AM
DiegoLlamas
Esri Contributor

I'm using the Filter Widget in an application created with Web AppBuilder 2.11 Developer Edition.
The application needs to set the filter listed dropdown values programmatically from info obtained from the currently logged user.

In the image above I have set up the filter widget to ask for values from a field in a specific layer (Region in this example).
I want to show only a subset of all the regions that the widget shows by default.
 
Is there a way to specify programmatically the options that the dropdown must show?
 
Another possible approach to solve my situation is to make the Filter Widget respect the layer definition expression.
How can I do that? If the widget respects the layer definition expression, the dropdown will only show values returned 
from the definition expression? 

0 Kudos
2 Replies
LeoLiu1
Occasional Contributor

Hi Diego,

Are you using dijit/form/Select to build your dropdown list?

I recently did similar stuff for a client: the Recommendation Type changed when subject changed.

piece of the codes: 

_subjectChanged: function(){
if(this.selectedSubject.value == 'opportunity'){
    this.selectRecommendation.options = [
        {value: 'Farm-in (Drilling)', label: 'FARM-IN (DRILLING)', selected: true},
        {value: 'Farm-in (Seismic)', label: 'FARM-IN (SEISMIC)', selected: false},
        {value: 'Bidding', label: 'BIDDING', selected: false},
        {value: 'Studies (JSA)', label: 'STUDIES (JSA)', selected: false}
    ]
}else{
    this.selectRecommendation.options = [
        {value: 'Farm-out', label: 'FARM-OUT', selected: true},
        {value: 'Drilling', label: 'DRILLING', selected: false},
        {value: 'Seismic Acquisition', label: 'SEISMIC ACQUISITION', selected: false},
        {value: 'Relinquishment', label: 'RELINQUISHMENT', selected: false}
    ]
}
this.selectRecommendation.startup();
}

HTML: 

<div class="subjectTable" >
   <div class="subjectTableCol">
      <label>Subject: </label>
      <select class="subjectTableCol-select"
         data-dojo-type="dijit/form/Select"
         data-dojo-attach-point="selectedSubject"
         data-dojo-attach-event="change:_subjectChanged">
         <option value="opportunity" selected="selected">OPPORTUNITY</option>
         <option value="permit" selected="selected">PERMIT</option>
      </select>
   </div>
   <div class="subjectTableCol">
      <label>Recommendation Type: </label>
      <select class="subjectTableCol-select"
         data-dojo-type="dijit/form/Select"
         data-dojo-attach-point="selectRecommendation">
      </select>
   </div>
   <div class="subjectTableCol">
      <label>Reviewer: </label>
      <input
         class="subjectTableCol-select"
         data-dojo-type="dijit/form/TextBox"
         readOnly="true"
         id="reviewerName"
         data-dojo-attach-point="reviewerName" />
   </div>
</div>
0 Kudos
DiegoLlamas
Esri Contributor

Leo, thank you for your reply. Unfortunately, your recommendation did not work. It was the method we thought we could do it, but the filter uses a custom widget instead of a Select from Dojo.

0 Kudos