Can you show your code?I could not get an error.<?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">
<!-- Adobe FLEX SDK ver. 4.5.1 -->
<!-- ArcGIS API for FLEX ver. 2.5 -->
<s:layout>
<s:VerticalLayout gap="10"
paddingBottom="10"
paddingLeft="10"
paddingRight="10"
paddingTop="10" />
</s:layout>
<fx:Script>
<![CDATA[
import com.esri.ags.layers.supportClasses.Field;
import mx.collections.ArrayCollection;
private var arrFields:Array = new Array();
[Bindable]
private var gridSource:ArrayCollection = new ArrayCollection();
protected function onDateFieldAdd(event:MouseEvent):void
{
var name:String = getRandomString(6);
var alias:String = getRandomString(7);
var field:Field = createField(name, Field.TYPE_DATE, alias, 10);
arrFields.push(field);
gridSource = new ArrayCollection(arrFields);
}
protected function onDoubleFieldAdd(event:MouseEvent):void
{
var name:String = getRandomString(6);
var alias:String = getRandomString(7);
var field:Field = createField(name, Field.TYPE_DOUBLE, alias);
arrFields.push(field);
gridSource = new ArrayCollection(arrFields);
}
protected function onGeometryFieldAdd(event:MouseEvent):void
{
var name:String = getRandomString(6);
var alias:String = getRandomString(7);
var field:Field = createField(name, Field.TYPE_GEOMETRY, alias);
arrFields.push(field);
gridSource = new ArrayCollection(arrFields);
}
protected function onLongFieldAdd(event:MouseEvent):void
{
var name:String = getRandomString(6);
var alias:String = getRandomString(7);
var field:Field = createField(name, Field.TYPE_INTEGER, alias, 8);
arrFields.push(field);
gridSource = new ArrayCollection(arrFields);
}
protected function onIntFiledAdd(event:MouseEvent):void
{
var name:String = getRandomString(6);
var alias:String = getRandomString(7);
var field:Field = createField(name, Field.TYPE_SMALL_INTEGER, alias, 4);
arrFields.push(field);
gridSource = new ArrayCollection(arrFields);
}
private function createField(fieldName:String, fieldType:String, fieldAlias:String = null, fieldLength:int = 0):Field
{
var result:Field = null;
if (fieldName != null && fieldType != null)
{
result = new Field();
result.name = fieldName;
result.type = fieldType;
result.alias = fieldAlias;
if (fieldLength > 0)
{
result.length = fieldLength;
}
}
return result;
}
private function getRandomString(length:Number):String{
var a:String = "abcdefghijklmnopqrstuvwxyz";
var alphabet:Array = a.split("");
var randomString:String = "";
for (var i:Number = 0; i < length; i++){
randomString += alphabet[Math.floor(Math.random() * alphabet.length)];
}
return randomString;
}
]]>
</fx:Script>
<mx:HDividedBox width="100%"
height="100%">
<s:Panel width="50%"
height="100%">
<s:layout>
<s:VerticalLayout gap="10"
paddingTop="10"
paddingLeft="10"/>
</s:layout>
<s:Button label="Add date field"
click="onDateFieldAdd(event)" />
<s:Button label="Add double field"
click="onDoubleFieldAdd(event)" />
<s:Button label="Add geometry field"
click="onGeometryFieldAdd(event)" />
<s:Button label="Add long field"
click="onLongFieldAdd(event)" />
<s:Button label="Add int field"
click="onIntFiledAdd(event)" />
</s:Panel>
<s:Panel width="50%"
height="100%">
<s:DataGrid dataProvider="{gridSource}"
width="100%"
height="100%">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="name" />
<s:GridColumn dataField="alias" />
<s:GridColumn dataField="type" />
<s:GridColumn dataField="length" />
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:Panel>
</mx:HDividedBox>
</s:Application>