Use any webservice as source for combobox in editor component

695
1
03-28-2014 07:32 AM
LucaSimone
New Contributor III
Hi to all,

I developed a simple solution to use any web service as datasource for a combobox in the editor component.
We have several fields in features that refer to external ids, so I have to find a generic way to connect those data.

So my solution is to build programmatically the editor fields and with my custom IFieldRenderer propose a combobox with the label instead of the id.

There are 3 variables, the endpoint that is the webservice. The labelField that is the field from the webservice to use as label and valueField that is the value to save inside the feature.

Example:

var endpoint:String = "https://api.github.com/orgs/tirug/public_members";   // Editor Field configuration var field:FieldInspector = new FieldInspector(); field.featureLayer = featureLayer; field.fieldName = "user_id"; // feature field field.label = "Username"; field.visible = true;   // Setup the custom renderer var renderer:ClassFactory = new ClassFactory(CustomDataSourceComboRenderer);  renderer.properties = { labelField: "login", valueField: "id", endpoint: endpoint }; field.renderer = renderer; field.rendererIsEditor = true;   editor.attributeInspector.fieldInspectors = [ field ]


The complete solution is here:

https://gist.github.com/lukefx/9230816

Happy coding!
Tags (2)
0 Kudos
1 Reply
LucaSimone
New Contributor III
Hi guys,

I improved a little bit my code, now I'm using a spark ComboBox that permits input by the user, the result is like this:
As usual the ComboBox datasource is a Web Service where you can choose the label and value field.



The code for the component is here: https://gist.github.com/lukefx/10735071

My new component needs this library: https://github.com/CodeCatalyst/promise-as3 but could be completely agnostic using HTTPService directly.
0 Kudos