+ Reply to Thread
Results 1 to 43 of 43

Thread: Edit Widget Questions

  1. #1
    Jason Nielsen
    Join Date
    Apr 2010
    Posts
    72
    Points
    4
    Answers Provided
    4


    0

    Post Edit Widget Questions

    Is there a way to change the order of the attribute fields in the edit widget so they are not alphabetical but rather following the order they are in the xml file?

    My second question is 2.0 didn't support snapping but it was mentioned that it would be something later on. Can somebody let me know when they think this would be implemented?

    Thanks,

    Jason

  2. #2
    Sarthak Datt
    Join Date
    Jan 2010
    Posts
    143
    Points
    92
    Answers Provided
    14


    0

    Default Re: Edit Widget Questions

    Hey Jason,

    The Edit Widget is using the out-of-box Editor component. The Editor component uses AttributeInspector(http://help.arcgis.com/en/webapi/fle...ibuteInspector) to show/edit the attribute fields.

    You can order the fields by using AttributeInspectot.formItemsOrder(http://help.arcgis.com/en/webapi/fle...formItemsOrder) property

    Here's a sample of how it is done using the API(you could do something similar in the Edit Widget's code, In this case the fields are ordered using the fieldInspector) :
    http://help.arcgis.com/en/webapi/fle...ctorOutsideMap

    As far as snapping is concerned, it is not there right now, but we still have plans to add it sometime in a future release.

    Hope that helps.
    Sarthak Datt
    ESRI Flex Team

  3. #3
    Jason Nielsen
    Join Date
    Apr 2010
    Posts
    72
    Points
    4
    Answers Provided
    4


    0

    Default Re: Edit Widget Questions

    Thanks for the quick reply. I will take a look at the AttributeInspector and see what i can come up with.

  4. #4
    Joey Stone
    Join Date
    Apr 2010
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Have you had any luck getting your attributes in order, I am having the same problem.

  5. #5
    xiaoyi zhang
    Join Date
    Apr 2010
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Hi Datt,

    Is there anyway we can make the attributeInspector as floating widget. Right now, If I add a point and the attribute window extented to the outside of buttom map and I cannot move it.

    Thanks,

    xiaoyi zhang



    Quote Originally Posted by sdatt View Post
    Hey Jason,

    The Edit Widget is using the out-of-box Editor component. The Editor component uses AttributeInspector(http://help.arcgis.com/en/webapi/fle...ibuteInspector) to show/edit the attribute fields.

    You can order the fields by using AttributeInspectot.formItemsOrder(http://help.arcgis.com/en/webapi/fle...formItemsOrder) property

    Here's a sample of how it is done using the API(you could do something similar in the Edit Widget's code, In this case the fields are ordered using the fieldInspector) :
    http://help.arcgis.com/en/webapi/fle...ctorOutsideMap

    As far as snapping is concerned, it is not there right now, but we still have plans to add it sometime in a future release.

    Hope that helps.

  6. #6
    xiaoyi zhang
    Join Date
    Apr 2010
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Hi Sarthak,

    Can you point to me where I need to make a change to set field order?

    I tried

    1.

    private function basewidget_creationCompleteHandler(event:FlexEvent):void
    {
    editor.attributeInspector.setStyle("skinClass", EditWidgetAttributeInspectorSkin);
    editor.attributeInspector.formItemsOrder = "none";
    // The order of the form items. Possible values are "none" (no order), "label" (order by label value) and "fieldInspector" (order by the field inspector definition sequence).

    map.infoWindow.label = attributesLabel;
    editor.attributeInspector.addEventListener("attachmentGroupClicked", attachmentGroupClickedHandler);
    editor.attributeInspector.addEventListener("okButtonClicked", okButtonClickHandler);
    }

    2.

    private function populateEditor(array:Array):void
    {
    featureLayers = [];

    if (oplList && oplList.length > 0)
    {
    for (var j:int = 0; j < oplList.length; j++)
    {
    var opLayerType:String = oplList[j].type

    var doNotAddFeatureLayer:Boolean = false;
    if (opLayerType.toLowerCase() == "feature")
    {
    // loop through all the excludeLayers
    for (var n:int = 0; n < excludeLayers.length; )
    {
    if (oplList[j].layer.name == excludeLayers[n])
    {
    doNotAddFeatureLayer = true;
    break;
    }
    else
    {
    n++;
    }
    }

    if (!doNotAddFeatureLayer)
    {
    // always turn the layer on by default
    oplList[j].visible = true;
    ViewerContainer.dispatchEvent(new AppEvent(AppEvent.MAP_LAYER_VISIBLE, oplList[j]));

    oplList[j].layer.removeEventListener(FeatureLayerEvent.SELECTION_COMPLETE, featureLayer_selectionComplete);
    oplList[j].layer.addEventListener(FeatureLayerEvent.SELECTION_COMPLETE, featureLayer_selectionComplete, false, 1);

    //store the infoWindowRendere foe each feature layer
    dictionary[oplList[j].layer] = oplList[j].layer.infoWindowRenderer;
    oplList[j].layer.infoWindowRenderer = null; // assign it to null, as editor overtakes now

    featureLayers.push(oplList[j].layer);
    }
    }
    }
    }

    // always call deactive first
    deactivateEditor();
    if (featureLayers.length > 0)
    {
    editor.map = map;
    editor.featureLayers = featureLayers;
    editor.attributeInspector.formItemsOrder = "none";
    // The order of the form items. Possible values are "none" (no order), "label" (order by label value) and "fieldInspector" (order by the field inspector definition sequence).

    }
    }


    Both places did not change the field order.

    Thank you in advance

    xiaoyi zhang


    Quote Originally Posted by sdatt View Post
    Hey Jason,

    The Edit Widget is using the out-of-box Editor component. The Editor component uses AttributeInspector(http://help.arcgis.com/en/webapi/fle...ibuteInspector) to show/edit the attribute fields.

    You can order the fields by using AttributeInspectot.formItemsOrder(http://help.arcgis.com/en/webapi/fle...formItemsOrder) property

    Here's a sample of how it is done using the API(you could do something similar in the Edit Widget's code, In this case the fields are ordered using the fieldInspector) :
    http://help.arcgis.com/en/webapi/fle...ctorOutsideMap

    As far as snapping is concerned, it is not there right now, but we still have plans to add it sometime in a future release.

    Hope that helps.

  7. #7
    Stephen Luzny
    Join Date
    Jul 2010
    Posts
    12
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Xiaoyi Zhang,

    I'm trying to return the attributes to their original order, too, but I haven't been successful so far.

    It may be worth noting that the attributeInspector property of public class Editor is read-only (i.e. we can 'get' editor.attributeInspector, but we can not 'set' it). The public class AttributeInspector allows us to 'set' properties such as formItemsOrder. We can see that in action in the example at http://help.arcgis.com/en/webapi/fle...WindowEditable

    I'm not sure how to apply the sample code to the ArcGIS Viewer for Flex 2.1.

  8. #8
    David Treat
    Join Date
    Sep 2010
    Posts
    14
    Points
    0
    Answers Provided
    0


    0

    Default controlling attributes in the Edit Widget

    Here is an approach that worked for me. I created the function below and called it at the end of the existing basewidget_creationCompleteHandler function in EditWidget.mxml. You will have to substitute in your own feature service name instead of my "Draft Conservation Land," as well as your own field names. In addition to controlling the order of the attributes this puts user friendly labels on them. And omits some attributes from the editing window.

    I am sure there is a more elegant coding approach to this, but I have not yet had time to optimize it. Hope it helps!

    Dave

    Code:
    // This function establishes the attribute edit environment.
    // In particular, the order in which fields are presented,
    // and the labels attached to those fields.  Lastly, fields
    // that should not be user editable are made not visible.
    
    private function createFieldInspectors():void
    {
    	editor.attributeInspector.formItemsOrder = "fieldInspector";
    	var layer:Layer;
    	var fLayer:FeatureLayer;
    	layer = map.getLayer("Draft Conservation Land");
    	fLayer = layer as FeatureLayer;
    	
    	var field0:FieldInspector = new FieldInspector();
    	field0.featureLayer = fLayer;
    	field0.fieldName = "NAME";
    	field0.label = "Parcel Name";
    	editor.attributeInspector.fieldInspectors.push(field0);
    			
    	var field0a:FieldInspector = new FieldInspector();
    	field0a.featureLayer = fLayer;
    	field0a.fieldName = "P_RSIZE";
    	field0a.label = "Parcel Size (acres)";
    	editor.attributeInspector.fieldInspectors.push(field0a);
    				
    	var field0b:FieldInspector = new FieldInspector();
    	field0b.featureLayer = fLayer;
    	field0b.fieldName = "RSIZE";
    	field0b.label = "Tract Size (acres)";
    	editor.attributeInspector.fieldInspectors.push(field0b);
    				
    	var field1:FieldInspector = new FieldInspector();
    	field1.featureLayer = fLayer;
    	field1.fieldName = "PPTYPE";
    	field1.label = "Primary Protection Type";
    	editor.attributeInspector.fieldInspectors.push(field1);
    				
    	var field2:FieldInspector = new FieldInspector();
    	field2.featureLayer = fLayer;
    	field2.fieldName = "PPAGENCY";
    	field2.label = "Primary Protection Agency";
    	editor.attributeInspector.fieldInspectors.push(field2);
    				
    	var field3:FieldInspector = new FieldInspector();
    	field3.featureLayer = fLayer;
    	field3.fieldName = "PROGRAM";
    	field3.label = "Protection Program";
    	editor.attributeInspector.fieldInspectors.push(field3);
    				
    	// fields to omit from user editing
    	var fieldx1:FieldInspector = new FieldInspector();
    	fieldx1.featureLayer = fLayer;
    	fieldx1.fieldName = "TID";
    	fieldx1.visible = false;
    	editor.attributeInspector.fieldInspectors.push(fieldx1);
    				
    	var fieldx2:FieldInspector = new FieldInspector();
    	fieldx2.featureLayer = fLayer;
    	fieldx2.fieldName = "PID";
    	fieldx2.visible = false;
    	editor.attributeInspector.fieldInspectors.push(fieldx2);
    				
    	var fieldx3:FieldInspector = new FieldInspector();
    	fieldx3.featureLayer = fLayer;
    	fieldx3.fieldName = "CSIZE";
    	fieldx3.visible = false;
    	editor.attributeInspector.fieldInspectors.push(fieldx3);
    				
    	var fieldx4:FieldInspector = new FieldInspector();
    	fieldx4.featureLayer = fLayer;
    	fieldx4.fieldName = "P_CSIZE";
    	fieldx4.visible = false;
    	editor.attributeInspector.fieldInspectors.push(fieldx4);
    }
    Last edited by dtreat; 12-06-2010 at 03:04 PM.

  9. #9
    Stephen Luzny
    Join Date
    Jul 2010
    Posts
    12
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Thanks, Dave. Your code sample is very helpful :-)

  10. #10
    Stephen Luzny
    Join Date
    Jul 2010
    Posts
    12
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Dave,

    I have modified your code to allow for configuration from the EditWidget XML configuration file.

    Add the following to EditWidget.xml:
    Code:
    <editablelayer>
    	<layername>Sample Layer</layername>
    	<fieldnames>FIELD1,FIELD2</fieldnames>
    	<fieldlabels>Field1,Field2</fieldlabels>
    	<hiddenfields>FIELD3</hiddenfields>
    </editablelayer>
    Within the EditWidget.mxml file:
    Code:
    [Bindable]
    private var showAttributesText:String;
    
    /* MODIFICATION -- setup variables for FieldInspector values from configXML */
    private var editableLayerName:String;
    private var editableLayerFieldNames:Array;
    private var editableLayerFieldLabels:Array;
    private var editableLayerHiddenFields:Array;
    /* MODIFICATION --  END */
    
    private function basewidget_widgetConfigLoaded(event:Event):void
    {
    	// hide map infowindow if any
    	map.infoWindow.hide();
    	
    	if (configXML)
    	{
    		
    		// MODIFICATION --  load configuration values for FieldInspector into variables
    		editableLayerName = configXML.editablelayer.layername;
    		
    		if (configXML.editablelayer.fieldnames.length() > 0)
    		{
    			// add field names to array
    			editableLayerFieldNames = [];
    		
    				const tempFieldArray:Array = configXML.editablelayer.fieldnames.split(",");
    				for (var count1:Number = 0; count1 < tempFieldArray.length; count1++)
    				{
    					editableLayerFieldNames.push(tempFieldArray[count1]);
    				}
    		}
    		
    		if (configXML.editablelayer.fieldlabels.length() > 0)
    		{
    			// add field labels to array
    			editableLayerFieldLabels = [];
    			
    			const tempLabelArray:Array = configXML.editablelayer.fieldlabels.split(",");
    			for (var counter2:Number = 0; counter2 < tempLabelArray.length; counter2++)
    			{
    				editableLayerFieldLabels.push(tempLabelArray[counter2]);
    			}
    		}
    
    		if (configXML.editablelayer.fieldlabels.length() > 0)
    		{
    			// add names of hidden fields to array
    			editableLayerHiddenFields = [];
    			
    			const tempHiddenFieldArray:Array = configXML.editablelayer.hiddenfields.split(",");
    			for (var count3:Number = 0; count3 < tempHiddenFieldArray.length; count3++)
    			{
    				editableLayerHiddenFields.push(tempHiddenFieldArray[count3]);
    			}
    		}
    		// MODIFICATION -- END
    		
    		geometryService.url = configXML.geometryservice;
    		
    		const configToolbarVisible:Boolean = configXML.toolbarvisible == "true";
    		editor.toolbarVisible = configToolbarVisible;
    		
    		const configToolbarCutVisible:Boolean = configXML.toolbarcutvisible == "true";
    		editor.toolbarCutVisible = configToolbarCutVisible;
    		
    		const configToolbarMergeVisible:Boolean = configXML.toolbarmergevisible == "true";
    		editor.toolbarMergeVisible = configToolbarMergeVisible;
    		
    		const configToolbarReshapeVisible:Boolean = configXML.toolbarreshapevisible == "true";
    		editor.toolbarReshapeVisible = configToolbarReshapeVisible;
    		
    		if (configXML.createoptions.length() > 0)
    		{
    			createOptions.polygonDrawTools = new Array();
    			createOptions.polylineDrawTools = new Array();
    			
    			if (configXML.createoptions.polygondrawtools.length() > 0)
    			{
    				const polygonDrawToolsList:Array = configXML.createoptions.polygondrawtools.split(",");
    				for (var i:Number = 0; i < polygonDrawToolsList.length; i++)
    				{
    					createOptions.polygonDrawTools.push(polygonDrawToolsList[i]);
    				}
    			}
    			
    			if (configXML.createoptions.polylinedrawtools.length() > 0)
    			{
    				const polylineDrawToolsList:Array = configXML.createoptions.polylinedrawtools.split(",");
    				for (var j:Number = 0; j < polylineDrawToolsList.length; j++)
    				{
    					createOptions.polylineDrawTools.push(polylineDrawToolsList[j]);
    				}
    			}
    			editor.createOptions = createOptions;
    		}
    		//excludeLayers
    		excludeLayers = [];
    		var layers:XMLList = configXML.excludelayer as XMLList;
    		for (var n:Number = 0; n < layers.length(); n++)
    		{
    			excludeLayers.push(layers[n].toString());
    		}
    		
    		//deleteFeatures
    		if (configXML.deletefeatures.length() > 0)
    		{
    			deleteFeatures = configXML.deletefeatures == "true";
    		}
    		editor.deleteEnabled = attachmentInspector.deleteEnabled = deleteFeatures;
    		
    		
    		//labels
    		if (configXML.labels.attributeslabel[0])
    		{
    			attributesLabel = configXML.labels.attributeslabel[0];
    		}
    		if (configXML.labels.attachmentslabel[0])
    		{
    			attachmentsLabel = configXML.labels.attachmentslabel[0];
    		}
    		
    		// featurelayernotvisibletext
    		EditWidgetTemplatePickerSkin.featureLayerNotVisibleText = configXML.featurelayernotvisibletext || "feature layer is either not visible or out of scale range";
    		// showattachmentstext
    		EditWidgetAttributeInspectorSkin.showAttachmentsText = configXML.showattachmentstext || "Show Attachments";
    		// showattributestext
    		showAttributesText = configXML.showattributestext || "Show Attributes";
    	}
    	
    	// MODIFICATION -- call function to setup FieldInspector
    	createFieldInspectors();
    	// MODIFICATION -- END
    	
    	map.infoWindow.addEventListener(Event.CLOSE, infoWindowCloseHandler);
    	ViewerContainer.dispatchEvent(new AppEvent(AppEvent.DATA_OPT_LAYERS, null, getOplayers));
    }
    And add the following function to EditWidget.mxml as well:
    Code:
    // This function establishes the attribute edit environment.
    // In particular, the order in which fields are presented,
    // and the labels attached to those fields.  Lastly, fields
    // that should not be user editable are made not visible.
    private function createFieldInspectors():void
    {
    	editor.attributeInspector.formItemsOrder = "fieldInspector";
    	var layer:Layer;
    	var fLayer:FeatureLayer;
    
    	layer = map.getLayer(editableLayerName);
    	fLayer = layer as FeatureLayer;
    	
    	var field:FieldInspector;
    	var fieldHidden:FieldInspector;
    	
    	// Setup FieldInspectors for visible fields
    	// Assumption: both editableLayerFieldNames and editableLayerFieldLabels will have the same number of elements
    	for (var i:Number = 0; i < editableLayerFieldNames.length; i++)
    	{
    		field = new FieldInspector();
    		field.featureLayer = fLayer;
    		field.fieldName = editableLayerFieldNames[i];
    		field.label = editableLayerFieldLabels[i];
    		editor.attributeInspector.fieldInspectors.push(field);
    	}
    	
    	// Setup FieldInspectors for hidden fields
    	for (var j:Number = 0; j < editableLayerHiddenFields.length; j++)
    	{
    		fieldHidden = new FieldInspector();
    		fieldHidden.featureLayer = fLayer;
    		fieldHidden.fieldName = editableLayerHiddenFields[j];
    		fieldHidden.visible = false;
    		editor.attributeInspector.fieldInspectors.push(fieldHidden);
    	}
    }

  11. #11
    Harold Bostic
    Join Date
    Apr 2010
    Posts
    158
    Points
    3
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Thank you all. I modified the code above to work with multiple editable layers

    Add the following to the editwidget.xml
    Code:
    <editablelayers>
        	<editablelayer>
    	  <layername>Sample Layer</layername>
    	  <fieldnames>FIELD1,FIELD2</fieldnames>
    	  <fieldlabels>Field1,Field2</fieldlabels>
    	  <hiddenfields>FIELD3</hiddenfields>
                 </editablelayer>
                 <editablelayer>
    	  <layername>Sample Layer 2</layername>
    	  <fieldnames>FIELD1,FIELD2</fieldnames>
    	  <fieldlabels>Field1,Field2</fieldlabels>
    	  <hiddenfields>FIELD3</hiddenfields>
                 </editablelayer>
    <editablelayers>
    Within the EditWidget.mxml file:
    Code:
    private function basewidget_widgetConfigLoaded(event:Event):void
                {
                    // hide map infowindow if any
                    map.infoWindow.hide();
    
                    if (configXML)
                    {
    
                        geometryService.url = configXML.geometryservice;
    
                        const configToolbarVisible:Boolean = configXML.toolbarvisible == "true";
                        editor.toolbarVisible = configToolbarVisible;
    
                        const configToolbarCutVisible:Boolean = configXML.toolbarcutvisible == "true";
                        editor.toolbarCutVisible = configToolbarCutVisible;
    
                        const configToolbarMergeVisible:Boolean = configXML.toolbarmergevisible == "true";
                        editor.toolbarMergeVisible = configToolbarMergeVisible;
    
                        const configToolbarReshapeVisible:Boolean = configXML.toolbarreshapevisible == "true";
                        editor.toolbarReshapeVisible = configToolbarReshapeVisible;
    
                        if (configXML.createoptions.length() > 0)
                        {
                            createOptions.polygonDrawTools = new Array();
                            createOptions.polylineDrawTools = new Array();
    
                            if (configXML.createoptions.polygondrawtools.length() > 0)
                            {
                                const polygonDrawToolsList:Array = configXML.createoptions.polygondrawtools.split(",");
                                for (var i:Number = 0; i < polygonDrawToolsList.length; i++)
                                {
                                    createOptions.polygonDrawTools.push(polygonDrawToolsList[i]);
                                }
                            }
    
                            if (configXML.createoptions.polylinedrawtools.length() > 0)
                            {
                                const polylineDrawToolsList:Array = configXML.createoptions.polylinedrawtools.split(",");
                                for (var j:Number = 0; j < polylineDrawToolsList.length; j++)
                                {
                                    createOptions.polylineDrawTools.push(polylineDrawToolsList[j]);
                                }
                            }
                            editor.createOptions = createOptions;
                        }
                        //excludeLayers
                        excludeLayers = [];
                        var layers:XMLList = configXML.excludelayer as XMLList;
    					
                        for (var n:Number = 0; n < layers.length(); n++)
                        {
                            excludeLayers.push(layers[n].toString());
                        }
    
                        //deleteFeatures
                        if (configXML.deletefeatures.length() > 0)
                        {
                            deleteFeatures = configXML.deletefeatures == "true";
                        }
                        editor.deleteEnabled = attachmentInspector.deleteEnabled = deleteFeatures;
    
    
                        //labels
                        if (configXML.labels.attributeslabel[0])
                        {
                            attributesLabel = configXML.labels.attributeslabel[0];
                        }
                        if (configXML.labels.attachmentslabel[0])
                        {
                            attachmentsLabel = configXML.labels.attachmentslabel[0];
                        }
    					
    					/*MODIFICATIONS */
    					var editablelayers:XMLList = configXML.editablelayers as XMLList;
    					var editableLayerFieldNames:Array;
    					var editableLayerFieldLabels:Array;
    					var editableLayerHiddenFields:Array;
    					
    					for each(var eLayer:XML in  editablelayers.children())
    					{
    							
    						
    						if (eLayer.fieldnames.length() > 0)
    						{
    							// add field names to array
    							editableLayerFieldNames = [];
    							
    							const tempFieldArray:Array = eLayer.fieldnames.split(",");
    							for (var count1:Number = 0; count1 < tempFieldArray.length; count1++)
    							{
    								editableLayerFieldNames.push(tempFieldArray[count1]);
    							}
    						}
    						
    						if (eLayer.fieldlabels.length() > 0)
    						{
    							// add field labels to array
    							editableLayerFieldLabels = [];
    							
    							const tempLabelArray:Array = eLayer.fieldlabels.split(",");
    							for (var counter2:Number = 0; counter2 < tempLabelArray.length; counter2++)
    							{
    								editableLayerFieldLabels.push(tempLabelArray[counter2]);
    							}
    						}
    						
    						if (eLayer.fieldlabels.length() > 0)
    						{
    							// add names of hidden fields to array
    							editableLayerHiddenFields = [];
    							
    							const tempHiddenFieldArray:Array = eLayer.hiddenfields.split(",");
    							for (var count3:Number = 0; count3 < tempHiddenFieldArray.length; count3++)
    							{
    								editableLayerHiddenFields.push(tempHiddenFieldArray[count3]);
    							}
    						}
    						
    						createFieldInspectors(eLayer.layername,editableLayerFieldNames,editableLayerFieldLabels,editableLayerHiddenFields);
    					}
    					
    					// MODIFICATION -- END
    					
                        // featurelayernotvisibletext
                        EditWidgetTemplatePickerSkin.featureLayerNotVisibleText = configXML.featurelayernotvisibletext || "feature layer is either not visible or out of scale range";
                        // showattachmentstext
                        EditWidgetAttributeInspectorSkin.showAttachmentsText = configXML.showattachmentstext || "Show Attachments";
                        // showattributestext
                        showAttributesText = configXML.showattributestext || "Show Attributes";
    					
    					
                    }
    				
    
                    map.infoWindow.addEventListener(Event.CLOSE, infoWindowCloseHandler);
                    ViewerContainer.dispatchEvent(new AppEvent(AppEvent.DATA_OPT_LAYERS, null, getOplayers));
                }
    And add the following function to EditWidget.mxml as well:
    Code:
    // This function establishes the attribute edit environment.
    			// In particular, the order in which fields are presented,
    			// and the labels attached to those fields.  Lastly, fields
    			// that should not be user editable are made not visible.
    			private function createFieldInspectors(editableLayerName:String,
    												   editableLayerFieldNames:Array,
    												   editableLayerFieldLabels:Array,
    												   editableLayerHiddenFields:Array):void
    			{
    				editor.attributeInspector.formItemsOrder = "fieldInspector";
    				var layer:Layer;
    				var fLayer:FeatureLayer;
    				
    				layer = map.getLayer(editableLayerName);
    				//if layer is null, you entered the wrong name in the layername tag of the specific editablelayer
    				if(!layer) return;
    				fLayer = layer as FeatureLayer;
    				
    				var field:FieldInspector;
    				var fieldHidden:FieldInspector;
    				
    				// Setup FieldInspectors for visible fields
    				// Assumption: both editableLayerFieldNames and editableLayerFieldLabels will have the same number of elements
    				for (var i:Number = 0; i < editableLayerFieldNames.length; i++)
    				{
    					
    					field = new FieldInspector();
    					field.featureLayer = fLayer;
    					field.fieldName = editableLayerFieldNames[i];
    					field.label = editableLayerFieldLabels[i];
    					editor.attributeInspector.fieldInspectors.push(field);
    				}
    				
    				// Setup FieldInspectors for hidden fields
    				for (var j:Number = 0; j < editableLayerHiddenFields.length; j++)
    				{
    					fieldHidden = new FieldInspector();
    					fieldHidden.featureLayer = fLayer;
    					fieldHidden.fieldName = editableLayerHiddenFields[j];
    					fieldHidden.visible = false;
    					editor.attributeInspector.fieldInspectors.push(fieldHidden);
    				}
    			}

  12. #12
    Jon Fisher
    Join Date
    Apr 2010
    Posts
    233
    Points
    2
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    This is really helpful, any chance of uploading this as a custom widget (both compiled and source code) to the code gallery to make it easier to find? I'm happy to make the changes in FlexBuilder, but everyone has it. I think I'm going to keep the original edit widget as well, so people can choose from the default one which requires less work to configure, and this one which provides much more customization. Thanks for all the code!

  13. #13
    Thomas Schultz
    Join Date
    Apr 2010
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    This post has been really helpful. However, I am having trouble setting the AttributeInspector formItemsOrder property. This should be really easy and straightforward. I'm using the function below to create my field inspectors and set the formItemsOrder property, the same way that others have done in the post. But my fields are still not in the correct order, and when I debug I find that the formItemsOrder property is still set to the default "label" value. Anyone have any idea why the formItemsOrder property won't set for me?

    Code:
    private function createFieldInspectors():void
    			{
    				var layer:Layer;
    				var fLayer:FeatureLayer;
    			
    				layer = map.getLayer(editableLayerName);
    				fLayer = layer as FeatureLayer;
    				
    				editor.attributeInspector.formItemsOrder = "fieldInspector";
    				
    				var field:FieldInspector;
    				var fieldHidden:FieldInspector;
    				
    				// Setup FieldInspectors for visible fields
    				// Assumption: both editableLayerFieldNames and editableLayerFieldLabels will have the same number of elements
    				for (var i:Number = 0; i < editableLayerFieldNames.length; i++)
    				{
    					field = new FieldInspector();
    					field.featureLayer = fLayer;
    					field.fieldName = editableLayerFieldNames[i];
    					field.label = editableLayerFieldLabels[i];
    					editor.attributeInspector.fieldInspectors.push(field);
    				}
    				
    				// Setup FieldInspectors for hidden fields
    				for (var j:Number = 0; j < editableLayerHiddenFields.length; j++)
    				{
    					fieldHidden = new FieldInspector();
    					fieldHidden.featureLayer = fLayer;
    					fieldHidden.fieldName = editableLayerHiddenFields[j];
    					fieldHidden.visible = false;
    					editor.attributeInspector.fieldInspectors.push(fieldHidden);
    				}
    			}
    Last edited by toejeep; 03-15-2011 at 06:14 AM.

  14. #14
    Thomas Schultz
    Join Date
    Apr 2010
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Sorry, I was debugging at the wrong point. Setting the formItemsOrder property to "fieldInspector" is not my issue. My field inspectors are also creating correctly. But my fields are still out of order. Any help would be greatly appreciated.

  15. #15
    Bob Mandel
    Join Date
    Jan 2011
    Posts
    33
    Points
    4
    Answers Provided
    2


    0

    Default Re: Edit Widget Questions

    Greetings all!

    I'm finding the code samples here to be very useful, especially the extention of functionality controlled by the EditWidget.xml file, but can anyone point me to a good comprehensive review of all the base tags that the EditWidget understands out of the box? Or are the ones that come in the base widget xml code the only ones that it does? I've been looking for a good disussion on this but have so far not come up with a good definitive answer ...

    Case in point, I can add my outFields list directly when coding a FeatureLayer directly in an application but am not finding a compatible xml option in either the base config.xml for the flex viewer or the EditWidget.xml file. Same goes for the ClassBreaksRenderer ...

    - Bob

  16. #16
    Jon Fisher
    Join Date
    Apr 2010
    Posts
    233
    Points
    2
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Quote Originally Posted by bobness View Post
    Greetings all!

    I'm finding the code samples here to be very useful, especially the extention of functionality controlled by the EditWidget.xml file, but can anyone point me to a good comprehensive review of all the base tags that the EditWidget understands out of the box?
    - Bob
    The ESRI help page lists the tags that work out of the box:
    http://help.arcgis.com/en/webapps/fl...000000v000000/

  17. #17
    J oN
    Join Date
    Apr 2010
    Posts
    85
    Points
    1
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Just trying to get the code posted here to work but not having much luck. I am trying the last version posted. In the xml posted a closing slash is missing on one of the tags, I added import com.esri.ags.components.supportclasses.FieldInspector because the compiler didn't know what a field inspector was, and I added back in the labels which appeared to have been removed in the posted code (the ok button didn't even have a label), and of course I added the new sections in the xml file. What else am I missing? There is no change in the widget's behavior from the original when I run it...
    Last edited by NeoGeo; 07-22-2011 at 12:16 PM.

  18. #18
    Ahmad Tarmizi Talib
    Join Date
    Aug 2011
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    does these codes work with flexviewer-2.3.1 and acrgis 10 (i notice some differences between the original edit widget code posted above with mine)? i tried both codes too but seems like they did nothing for me. the arrangement is still alphabetical. what could possibly went wrong? =\

  19. #19
    Jos Vroegop
    Join Date
    Oct 2010
    Posts
    46
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Thanks guys, just what i was looking for.

    Used the code from Harold Bostic's post in 2.4 viewer, works like a charm.
    Esri should make this standard functionality for the edit widget in my opinion.
    Last edited by jvroegop; 09-23-2011 at 02:15 AM.

  20. #20
    dmitry pylnev
    Join Date
    Mar 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Hi! There is a question whether it is possible in a widget in the fields of attributes to write fractions? (field on the GIS server fractional numeric)

  21. #21
    Karl Wilson
    Join Date
    Oct 2010
    Posts
    110
    Points
    12
    Answers Provided
    0


    0

    Question Re: Edit Widget Questions

    I'm having difficulty getting this to work for 2.4.

    I've copied in the code between the /*MODIFICATIONS*/ comments in hbostic's post to the basewidget_widgetConfigLoaded function within the if (configXML) statement, and added the createFieldInspectors function. I assume the rest of the EditWidget.mxml displayed was from a version previous to 2.4.

    I also added the import com.esri.ags.components.supportClasses.FieldInspector; statement and added the closing slash in the </editablelayers> xml tag, as mentioned by NeoGeo.

    When I run the widget I see no difference in the widgets behaviour. Can anyone who has managed to get this to work please offer some help? (jvroegop maybe?)

    Cheers,
    Karl

    Attached is my full EditWidget.mxml
    Attached Files
    Last edited by kwgis; 10-12-2011 at 01:56 AM.

  22. #22
    Ben Kane
    Join Date
    Jun 2011
    Posts
    56
    Points
    12
    Answers Provided
    2


    0

    Default Re: Edit Widget Questions

    Karl,
    If you succeeded in compiling it with the modifications then it is all about the <fieldnames>, <fieldlabels> and <hiddenfields> tags in the xml file. Specify the order you want the fields to display in the attribute inspector window with <fieldnames> and assign aliases in <fieldlabels> in the same order. Any field you put in <hiddenfields> do not put in within the other two tags. This should work, worked for me...

    Ben

    Quote Originally Posted by kwgis View Post
    I'm having difficulty getting this to work for 2.4.

    I've copied in the code between the /*MODIFICATIONS*/ comments in hbostic's post to the basewidget_widgetConfigLoaded function within the if (configXML) statement, and added the createFieldInspectors function. I assume the rest of the EditWidget.mxml displayed was from a version previous to 2.4.

    I also added the import com.esri.ags.components.supportClasses.FieldInspector; statement and added the closing slash in the </editablelayers> xml tag, as mentioned by NeoGeo.

    When I run the widget I see no difference in the widgets behaviour. Can anyone who has managed to get this to work please offer some help? (jvroegop maybe?)

    Cheers,
    Karl

    Attached is my full EditWidget.mxml

  23. #23
    Karl Wilson
    Join Date
    Oct 2010
    Posts
    110
    Points
    12
    Answers Provided
    0


    0

    Red face Re: Edit Widget Questions

    Thanks Ben.

    OK I got it working, the issue was human error on my part. I had been modifying the EditWidget.mxml of a different project to the one I was compiling. Duh.

    I've updated the attachement on my previous post with the correct EditWidget.mxml.

    Karl

  24. #24
    mei 09
    Join Date
    Jun 2010
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    this has been an interesting thread.

    I was wondering if anyone has been able to dyamically change the fields that are availabe for editing during different stages, i.e:
    1) create new features : all attribute fields are editable
    2) update existing features: only some fields are editable

    would appreciate if anyone could point out if this is possible and which event should be used to capture this?

    thanks
    mei

  25. #25
    M Giles
    Join Date
    Jan 2012
    Posts
    94
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Can somebody explain why this only works for layers type feature - using the FeatureServer rest feed. The layers that are editable in my application are type dynamic and the edit widget does not honor the field orders from the xml..

  26. #26
    Harold Bostic
    Join Date
    Apr 2010
    Posts
    158
    Points
    3
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    It's just how the REST endpoint was implemented. That way you can perform CRUD operations at a feature level or over an array of features. If you have access to the data being published, you can simply enable feature service access when publishing your map. Also, be sure you are using an SDE database if you want to leverage the editing capabilities.

    See the specification for more detail -> http://services.arcgisonline.com/Arc.../overview.html

  27. #27
    M Giles
    Join Date
    Jan 2012
    Posts
    94
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    I am using an SDE database and I do have access to enable feature service. My problem is that i have three layers that are editable: Working Points, Working Lines, Working Polygons. These three layers need to be grouped in my TOC. Since I cant group feature services in the TOC on the flex side, I am forced to group the layers in the mxd and call the service as dynamic using the MapServer feed...

  28. #28
    Brad Fisher
    Join Date
    Jul 2010
    Posts
    90
    Points
    10
    Answers Provided
    1


    0

    Default Re: Edit Widget Questions

    I posted this idea a while ago but have just come across the issue again & came across this post.

    Appreciate your support to getting this introduced @ the feature service level configuration.

    Brad
    Brad Fisher
    -------------
    Sopra Group
    @gisfish

  29. #29
    Rachel B
    Join Date
    Apr 2010
    Posts
    106
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Hi,
    I'm new to Flex, I'm not using Flex API just the standard Flex out of the box. But I need to reorder my fields and I need to hide some fields, since I can't use the mxml code, will I be able to carry out this using just the first bit if code the above posts say to paste into the xml?
    I'm using Flex 2.5 and have so far been able to edit the widget and config file to edit my dataset, but I'm now stuck on reordering fields and hiding fields.

    PLease help.
    Thanks
    Rachel

  30. #30
    philipp schnetzer
    Join Date
    Apr 2010
    Posts
    390
    Points
    51
    Answers Provided
    12


    2

    Default Re: Edit Widget Questions

    Rachel,

    The code above requires a function be inserted into mxml...so you are out of luck using only the compiled version. However, you may have some success if you go to properties of your layer in ArcMap and hit the Fields tab - there you can check on/off certain fields, re-order and create aliases - as far as I know the Edit widget respects those changes made in the field properties...

  31. #31
    Rachel B
    Join Date
    Apr 2010
    Posts
    106
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Thanks Philipp,
    That's shame, I hope it goes into the code gallery soon, as it's a very useful widget.
    The Edit Widget unfortunately doesn't respect the changes made to the field Order in the mxd, although it honours field aliases. I don't know why the default order is alphabetical, since the way you would have the fields ordered in the mxd, is the way they should show in the flex.
    Rachel

  32. #32
    heather Grybas
    Join Date
    Jun 2011
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Hi Rachel,

    I had the same problem as you. I have several datasets that can be edited with the edit widget and they all have a number of fields that have to be filled in. The best work around I could find (since I know nothing about programing) was to number each field in the order you want using the field aliases. So for example when your alias might look like "1. [Name]" then go on to two ( " 2. [Name]") and so on in the order you want the fields to appear. The edit widget should list them according to number. It really wasn't the way I wanted my field names to look in the editor but at least they were in the right order.

    good luck!

    -Heather

  33. #33
    Rachel B
    Join Date
    Apr 2010
    Posts
    106
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Thanks for this Heather, this is a good work around in the mean time.
    On the plus side I've discovered that flex honours hidden fields without needing to add code unlike webadf.

    I have one other query I don't see on the forum all my text boxes are quite large. Is there any way of adjusting their size as it seems defaulted to the one size regardless of how many characters the field is in the mxd.

    Thanks

    Rachel

  34. #34
    Todd LaQuay
    Join Date
    Apr 2011
    Posts
    9
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    I am also not a programmer and numbering the aliases only works if you have fields 1 to 9, when you add that 10th field in, it gets placed between 1 and 2 (ex 1, 10, 2, 3) I have about 60 editable fields and order is important to the non GIS users to follow their forms and fill in. Does anyone have a suggestion for this issue?

    UPDATE: I found in other DB forums where they said to pad with 0's giving equal number of characters and that solved the issue. (ex 01,02,...09,10,11)
    Last edited by tlaquay; 05-22-2012 at 05:59 AM.

  35. #35
    Frank Roberts
    Join Date
    Apr 2010
    Posts
    143
    Points
    3
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    When the widget loads, it automatically turns on all the layers, independent of what you may have switched on or off. That seems to be the default behavior even in the sample provided at ESRI (I guess). However, with mine after the edit widget layer loads up and turns on all the layers, I can’t turn them off in the edit widget. I’m looking at the config file for the edit widget and am not seeing anything that would allow me to enable or disable this function.

    Anyone know how to allow me to turn layers off?
    Frank Roberts

    GeoDeveloper
    Innovate! Inc.
    Worley, Idaho USA

  36. #36
    Frank Roberts
    Join Date
    Apr 2010
    Posts
    143
    Points
    3
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Sorry but hopefully this helps someone. the answer to my above question is that the behavior I saw was from having the addfeature tag ( found in the editwidget.xml) set to false. When you do this it must not allow or accept clicking on the widget. So then you can't turn it off.
    Frank Roberts

    GeoDeveloper
    Innovate! Inc.
    Worley, Idaho USA

  37. #37
    J oN
    Join Date
    Apr 2010
    Posts
    85
    Points
    1
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Thanks to everyone that contributed!! I finally figured out my problem. For people who need a compiled version, here is a compiled swf (version 2.5). I included a small HowTo and and examle xml file as well as the mxml that was uploaded previously.

    Thanks again everyone!!
    Attached Files

  38. #38
    Pam Cowher
    Join Date
    Feb 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Is there a comparable fix to reorder/turn fields off in the 3.0 flex viewer. I thought the default Field Inspector option would do it but I can't find any documentation to set it up and have tried all the usual search locations. Any guidance would be appreiciated. I'm trying to move from 2.5 to 3. Thanks in advance.

  39. #39
    Jos Vroegop
    Join Date
    Oct 2010
    Posts
    46
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    I modified the standard 3.0 edit widget with code examples from Harold Bostic's post. Im not a flex programmer but it seems to work like it should. Maybe it's usefull to someone so here's a compiled and sourcecode version of my frankenstein.
    Attached Files

  40. #40
    Jos Vroegop
    Join Date
    Oct 2010
    Posts
    46
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Code in previous post has some weird behavior. When you create a new feature in a feature service that has attachments, the edit widget doesn't let you add attachments right away. A feature has to be created fist, then edited again if you want to add attachments. Does anyone know what to change to fix this?

  41. #41
    Bjorn Svensson

    Join Date
    Sep 2009
    Posts
    933
    Points
    287
    Answers Provided
    44


    0

    Default Re: Edit Widget Questions

    Quote Originally Posted by jvroegop View Post
    When you create a new feature in a feature service that has attachments, the edit widget doesn't let you add attachments right away. A feature has to be created fist, then edited again if you want to add attachments. Does anyone know what to change to fix this?
    Short answer: This is how it works in the ArcGIS API 3.0 for Flex (which is different from 2.x) and the underlying ArcGIS Server (an attachment can't be added until a feature has been created and exist on the server).

    Long answer: At 2.x when you clicked to create a feature, the request to create the feature was sent first, then the input boxes for attributes (and attachments) was popped up.

    ArcGIS 10.1 added the capability to allowed people to create, but not update, features – which (with the 2.x logic) would never work, as you wouldn't be able to set the attributes at all in this particular case.

    At 3.0, the created feature is not sent to the server until the attributes have been popped up and user clicked OK. Since you cannot add attachments to a feature until it exists, this also means that you can’t add an attachment in the same request. For future versions, we are considering an API enhancement to once again support the earlier workflow within the Edit widget.
    Bjorn Svensson
    Esri Flex team
    https://twitter.com/bjorn_svensson
    http://resources.arcgis.com/en/communities/flex-api/ (ArcGIS API 3.3 for Flex - released April 29, 2013)
    http://resources.arcgis.com/en/communities/flex-viewer/ (ArcGIS Viewer 3.3 for Flex - released April 29, 2013)

  42. #42
    Najya Batool
    Join Date
    Dec 2010
    Posts
    11
    Points
    0
    Answers Provided
    0


    0

    Default Re: Edit Widget Questions

    Hi. We've also upgraded from 2.5 to 3.0 and I'm struggling to reorder fields in the Edit widget. Does anyone know if this issue was resolved in 3.1?

    Thanks,
    Najya

  43. #43
    Najya Batool
    Join Date
    Dec 2010
    Posts
    11
    Points
    0
    Answers Provided
    0


    0

    Exclamation Re: Edit Widget Questions

    Hi ESRI FLEX Team,

    "For future versions, we are considering an API enhancement to once again support the earlier workflow within the Edit widget." BJORN

    Any further developments on the API?

    Thanks,
    Najya

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts