Select to view content in your preferred language

combobox in attribute inspector via 'customField' doesn't work

5080
4
Jump to solution
07-31-2013 12:09 PM
KaitlynnDavis
Regular Contributor
I would like to add a combobox to the attribute inspector using the customField property. I am following the sample Attribute Inspector with Custom Dijit, and the syntax for adding a combobox does not seem to reflect the pattern used to add the validation textbox in the sample. Trying the following code inhibits my features from being selectable, so clearly it is erroneous. I'm looking for some direction as to what I'm missing when I'm instantiating the combobox:

var myDijit = new dijit.form.ComboBox({         id: "select1",         value: "choose an option",         store: store     }, "select1");  var layerInfos = [{           'featureLayer':featureLayer,           'showAttachments':false,           'showDeleteButton':false,           'fieldInfos':[             {'fieldName':'summary','label':'Summary'},             {'fieldName':'asset_cat','label':'Asset cat.'},             {'fieldName':'linkage1','label':'linkage1','customField':myDijit},             {'fieldName':'date','label':'Date'}           ]         }];   
0 Kudos
1 Solution

Accepted Solutions
KaitlynnDavis
Regular Contributor
The purpose of this was to place a combobox inside of an attribute inspector so that it behaves like a field domain during an editing session. The new combobox is created within the initEditor function like so:
    docSelect = new dijit.form.ComboBox({         id: "docSelect",  name: "docSelect",  value: "Pick a Document",  store: store1,      }, "docSelect");


you then add it to the attribute inspector:

    var layers = dojo.map(results, function(result) {  return {   featureLayer:result.layer,   showAttachments:true,   showDeleteButton:true,   fieldInfos:[    {fieldName: "YOUR_FIELD", visible: true, 'tooltip': 'Document that the recommendation is from', 'label':"Doc. Title", 'customField': docSelect}   ]  };     });


Creating a domain and/or subsets within ArcMap is the simplest way to provide users with a predefined set of field values. However, say you need to have a field that dynamically filters based on an edit in another field (ex. U.S cities field filters based on the value one enters in States field); then placing a combobox that populates with a special query task may be the best option

View solution in original post

0 Kudos
4 Replies
KaitlynnDavis
Regular Contributor
The purpose of this was to place a combobox inside of an attribute inspector so that it behaves like a field domain during an editing session. The new combobox is created within the initEditor function like so:
    docSelect = new dijit.form.ComboBox({         id: "docSelect",  name: "docSelect",  value: "Pick a Document",  store: store1,      }, "docSelect");


you then add it to the attribute inspector:

    var layers = dojo.map(results, function(result) {  return {   featureLayer:result.layer,   showAttachments:true,   showDeleteButton:true,   fieldInfos:[    {fieldName: "YOUR_FIELD", visible: true, 'tooltip': 'Document that the recommendation is from', 'label':"Doc. Title", 'customField': docSelect}   ]  };     });


Creating a domain and/or subsets within ArcMap is the simplest way to provide users with a predefined set of field values. However, say you need to have a field that dynamically filters based on an edit in another field (ex. U.S cities field filters based on the value one enters in States field); then placing a combobox that populates with a special query task may be the best option
0 Kudos
MatthewMiller
Emerging Contributor
Was this issue every resolved?  I am currently experience a similar problem with adding a combo box to the Attribute Inspector.  When the inspector starts, the drop-down menu for the combo box does not work.

I can get a custom Validation TextBox to work, as is shown in the sample.  But, a combo box dijit does not.

Any advice would be appreciated.  Thanks!
0 Kudos
KaitlynnDavis
Regular Contributor
yeah, I got it working. The easiest approach is to use a select widget as so:

var mySelect = new Select({
 name:"mySelect",
 options: [
  {label: "Select option 1", value: "Select option 1"},
  {label: "Select option 2", value: "Select option 2"},
  {label: "Select option 3", value: "Select option 3"}
 ]
});


Then use the 'customField' property as is done in the esri sample, setting it equal to the variable name. A select is ideal if you don't have a massive list of options. The thing with comboboxes are that they are "store-enabled", so you can't follow the same options array format.

If combobox is specifically what you are looking for (you have a json store, you want to loop through a list of field values, are basing the list of values on a query, or just really want the autocomplete feature that comes with combobox) I will need some time to get back to you as it is a little more involved and I'm trying to get an app done before the weekend 😉

*note on the autocomplete thing -- look into the dojo filtering select. You might be able to set it up in the same way as you would with the select... I just haven't worked with it myself yet
0 Kudos
MatthewMiller
Emerging Contributor
Actually, I found that the combo box needed to be declared in the Editor in order to be recognized by the Attribute Inspector.  I have a config.js file that includes the layer info, which are loaded into a LayerInfos array when the layers are loaded to the map.  I had been declaring the combo box in that file, which worked with Validation Text Boxes for some reason. However, The combo box and its value store needed to be declared in the Editor widget.

The layerInfos for the Attribute Inspector can then set the 'customField' to the dijit.byId(" ") call to the combo box like so:

    
editorLayerInfos: {
         fieldInfos: [
               { 'fieldName': 'UtilityType', 'isEditable': true, 'customField': dijit.byId("UtilityTypeComboBox") },               
               ]
        } 


However, for some reason, this doesn't appear to work with a Validation Text Box, which has to have 'customField' pointing directly to the variable name.