Hi Folks,
Is there anyways to change the order of Flex Object's Property names?
For example,
var obj:Object = {id:121,name:some name,address:some address}
I have added this object into arraycollection and set that arraycollection as a dataprovider to datagrid. But the columns in the datagrid are not in the order(id,name,address), which I gave in the object. Instead it shows theproperty names in alphabatical order (address,id,name).
Any help much appreciated.
Thanks in advance.
With Regards,
Arun Ganesh. P
here is a solution using flex 4.6
<?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" minWidth="955" minHeight="600"
applicationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
[Bindable]
private var arrayList:ArrayList = new ArrayList();
private function init():void
{
for (var i:int = 0; i < 10; i++)
{
var obj:Object = { id: i, name:"name"+i, address:"address"+i };
arrayList.addItem(obj);
}
}
]]>
</fx:Script>
<s:DataGrid dataProvider="{arrayList}">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="id" width="50" />
<s:GridColumn dataField="name" width="100" />
<s:GridColumn dataField="address" width="200"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:Application>
North America
Europe, Middle East and Africa
Asia Pacific