I need to order an array of items by their item numbers on a datagrid in Flex 3.5.
I don't actually need to re-order it once it's inside the datagrid, I just need it to be sorted already on the arraycollection before sending it to the dataprovider.
My problem is that the proprety 'item_number' that I need to be sorted it's a string and it's built with the lot number and a dot, like this:
1.1, 1.2, 1.3, 2.1, 2.2, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11
I need it to be ordered like this.
If I try to just order them by number, 3.2 is bigger than 3.11, so it wouldn't work. I need to order them first by the integer before the dot and only after it, by the integer after the dot, before moving on to the next integer before the dot
Also I have another problem. The item_number attribute is inside an object that is inside another object on my arraycollection.
To get to it I have to:
array_collection.item.item_number
So to sum it up, I need to list an array ordered by an attribute that's inside another object of the arrayitem and it's a number on a string separated by dot.
This is a simplified version of my code:
<mx:Script>
<![CDATA[
public function print_data_grid(array_collection):void
{
my_data_grid.dataProvider = array_collection
}
]]>
</mx:Script>
<mx:DataGrid id="my_data_grid">
<mx:columns>
<mx:DataGridColumn headerText="# Item">
<mx:itemRenderer>
<mx:Component>
<mx:Label toolTip="{this.text}" text="{data.product.item_number}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Item Name">
<mx:itemRenderer>
<mx:Component>
<mx:Label toolTip="{this.text}" text="{data.product.name}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>