Select to view content in your preferred language

type of field

633
1
Jump to solution
04-19-2013 03:17 AM
lifeEsri
Occasional Contributor
hello everybody,
iI want to return type of the selected field from a combobox
some help pleaze 🙂
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IvanBespalov
Frequent Contributor
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"        xmlns:s="library://ns.adobe.com/flex/spark"        xmlns:mx="library://ns.adobe.com/flex/mx">    <s:layout>   <s:VerticalLayout gap="10"         paddingBottom="10"         paddingLeft="10"         paddingRight="10"         paddingTop="10" />  </s:layout>    <fx:Script>   <![CDATA[    import com.esri.ags.events.LayerEvent;    import com.esri.ags.layers.FeatureLayer;    import com.esri.ags.layers.supportClasses.Field;    import com.esri.ags.layers.supportClasses.LayerDetails;        import mx.controls.Alert;    import mx.controls.Label;        import spark.components.HGroup;        private var fLayer:FeatureLayer = null;        protected function onInitLayerClick(event:MouseEvent):void    {     fLayer = new FeatureLayer(txtUrl.text);     fLayer.outFields = new Array("*");     fLayer.addEventListener(LayerEvent.LOAD, onLayerLoad);     fLayer.addEventListener(LayerEvent.LOAD_ERROR, onLayerLoadError);     dispatchEvent(new LayerEvent(LayerEvent.LOAD, fLayer));    }        protected function onLayerLoad(event:LayerEvent):void    {     var layerDetails:LayerDetails = fLayer.layerDetails;     var fields:Array = layerDetails.fields;          groupContainer.removeAllElements();     for each (var field:Field in fields)     {      var hGroup:HGroup = new HGroup();      hGroup.gap = 5;            var lblName:Label = new Label();      lblName.width = 200;      lblName.text = "Name: " + field.name + ";";      hGroup.addElement(lblName);            var lblAlias:Label = new Label();      lblAlias.width = 200;      lblAlias.text = "Alias: " + field.alias + ";";      hGroup.addElement(lblAlias);            var lblNullable:Label = new Label();      lblNullable.width = 100;      lblNullable.text = field.nullable ? "Nullable" : "Not nullable;";      hGroup.addElement(lblNullable);            var lblType:Label = new Label();      lblType.width = 100;      switch (field.type)      {       case Field.TYPE_BLOB:        lblType.text = "Is Blob;";        break;       case Field.TYPE_DATE:        lblType.text = "Is date;";        break;       case Field.TYPE_DOUBLE:        lblType.text = "Is double;";        break;       case Field.TYPE_GEOMETRY:        lblType.text = "Is geometry;";        break;       case Field.TYPE_GUID:        lblType.text = "Is GUID;";        break;       case Field.TYPE_GLOBAL_ID:        lblType.text = "Is global id;";        break;       case Field.TYPE_INTEGER:        lblType.text = "Is integer;";        break;       case Field.TYPE_OID:        lblType.text = "Is object id;";        break;       case Field.TYPE_RASTER:        lblType.text = "Is raster;";        break;       case Field.TYPE_SINGLE:        lblType.text = "Is single;";        break;       case Field.TYPE_SMALL_INTEGER:        lblType.text = "Is short;";        break;       case Field.TYPE_STRING:        lblType.text = "Is text;";        break;       case Field.TYPE_XML:        lblType.text = "Is xml;";        break;      }      hGroup.addElement(lblType);            var lblEditable:Label = new Label();      lblEditable.width = 100;      lblEditable.text = field.editable ? "Editable" : "Not editable;";      hGroup.addElement(lblEditable);            if (field.length > 0)      {       var lblLength:Label = new Label();       lblLength.width = 100;       lblLength.text = "Field length: " + field.length;       hGroup.addElement(lblLength);      }            groupContainer.addElement(hGroup);     }    }        protected function onLayerLoadError(event:LayerEvent):void    {     Alert.show(event.fault.message.toString(), "Layer is not loaded");    }   ]]>  </fx:Script>        <s:TextInput id="txtUrl"      width="100%"      text="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/67"/>    <s:Button label="Initialize layer"       click="onInitLayerClick(event)"/>    <s:VGroup width="100%"      height="100%"      gap="5">      <s:Scroller width="100%"      height="100%">        <s:VGroup height="100%"       width="100%"       id="groupContainer"/>       </s:Scroller>     </s:VGroup>   </s:Application>


P.S. SDK 4.9.0; ArcGIS API for FLEX 3.2

View solution in original post

0 Kudos
1 Reply
IvanBespalov
Frequent Contributor
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"        xmlns:s="library://ns.adobe.com/flex/spark"        xmlns:mx="library://ns.adobe.com/flex/mx">    <s:layout>   <s:VerticalLayout gap="10"         paddingBottom="10"         paddingLeft="10"         paddingRight="10"         paddingTop="10" />  </s:layout>    <fx:Script>   <![CDATA[    import com.esri.ags.events.LayerEvent;    import com.esri.ags.layers.FeatureLayer;    import com.esri.ags.layers.supportClasses.Field;    import com.esri.ags.layers.supportClasses.LayerDetails;        import mx.controls.Alert;    import mx.controls.Label;        import spark.components.HGroup;        private var fLayer:FeatureLayer = null;        protected function onInitLayerClick(event:MouseEvent):void    {     fLayer = new FeatureLayer(txtUrl.text);     fLayer.outFields = new Array("*");     fLayer.addEventListener(LayerEvent.LOAD, onLayerLoad);     fLayer.addEventListener(LayerEvent.LOAD_ERROR, onLayerLoadError);     dispatchEvent(new LayerEvent(LayerEvent.LOAD, fLayer));    }        protected function onLayerLoad(event:LayerEvent):void    {     var layerDetails:LayerDetails = fLayer.layerDetails;     var fields:Array = layerDetails.fields;          groupContainer.removeAllElements();     for each (var field:Field in fields)     {      var hGroup:HGroup = new HGroup();      hGroup.gap = 5;            var lblName:Label = new Label();      lblName.width = 200;      lblName.text = "Name: " + field.name + ";";      hGroup.addElement(lblName);            var lblAlias:Label = new Label();      lblAlias.width = 200;      lblAlias.text = "Alias: " + field.alias + ";";      hGroup.addElement(lblAlias);            var lblNullable:Label = new Label();      lblNullable.width = 100;      lblNullable.text = field.nullable ? "Nullable" : "Not nullable;";      hGroup.addElement(lblNullable);            var lblType:Label = new Label();      lblType.width = 100;      switch (field.type)      {       case Field.TYPE_BLOB:        lblType.text = "Is Blob;";        break;       case Field.TYPE_DATE:        lblType.text = "Is date;";        break;       case Field.TYPE_DOUBLE:        lblType.text = "Is double;";        break;       case Field.TYPE_GEOMETRY:        lblType.text = "Is geometry;";        break;       case Field.TYPE_GUID:        lblType.text = "Is GUID;";        break;       case Field.TYPE_GLOBAL_ID:        lblType.text = "Is global id;";        break;       case Field.TYPE_INTEGER:        lblType.text = "Is integer;";        break;       case Field.TYPE_OID:        lblType.text = "Is object id;";        break;       case Field.TYPE_RASTER:        lblType.text = "Is raster;";        break;       case Field.TYPE_SINGLE:        lblType.text = "Is single;";        break;       case Field.TYPE_SMALL_INTEGER:        lblType.text = "Is short;";        break;       case Field.TYPE_STRING:        lblType.text = "Is text;";        break;       case Field.TYPE_XML:        lblType.text = "Is xml;";        break;      }      hGroup.addElement(lblType);            var lblEditable:Label = new Label();      lblEditable.width = 100;      lblEditable.text = field.editable ? "Editable" : "Not editable;";      hGroup.addElement(lblEditable);            if (field.length > 0)      {       var lblLength:Label = new Label();       lblLength.width = 100;       lblLength.text = "Field length: " + field.length;       hGroup.addElement(lblLength);      }            groupContainer.addElement(hGroup);     }    }        protected function onLayerLoadError(event:LayerEvent):void    {     Alert.show(event.fault.message.toString(), "Layer is not loaded");    }   ]]>  </fx:Script>        <s:TextInput id="txtUrl"      width="100%"      text="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/67"/>    <s:Button label="Initialize layer"       click="onInitLayerClick(event)"/>    <s:VGroup width="100%"      height="100%"      gap="5">      <s:Scroller width="100%"      height="100%">        <s:VGroup height="100%"       width="100%"       id="groupContainer"/>       </s:Scroller>     </s:VGroup>   </s:Application>


P.S. SDK 4.9.0; ArcGIS API for FLEX 3.2
0 Kudos