[flexcoders] Re: sort datagridcolumn on numeric field - use sortCompareFunction ?

2007-02-03 Thread amigo_fd
Solution found !

example and code on

http://flextricks.wordpress.com/2007/02/03/sorting-numeric-values-in-a-flex-datagrid/

--- In flexcoders@yahoogroups.com, "amigo_fd" <[EMAIL PROTECTED]> wrote:
>
> any ideas on how to do this with sortCompareFunction ?
> 
> --- In flexcoders@yahoogroups.com, "amigo_fd"  wrote:
> >
> > Hello, it looks like all data in a datagrid is treated as text. So if
> > you sort a column with only numeric fields it is sorted on the value
> > of the textual contect, instead of the numeric value, like this:
> > 
> > 1095
> > 111
> > 1276
> > 144
> > ...
> > 
> > I already converted my webservice-result to numbers at loading, but
> > sorting keeps using text-value ... How to change this ?
> > 
> > dgInvoiceListGrouped.dataProvider = new
XMLListCollection(x.children());
> > var GroupedArray:Array = [];
> > 
> > for (var j:Number = 0; j < dgInvoiceList.dataProvider.length; j++) {
> > GroupedArray[j] = {Name:
> > dgInvoiceListGrouped.dataProvider.getItemAt(j).Name.toString(),
> > Country:
> > dgInvoiceListGrouped.dataProvider.getItemAt(j).Country.toString(),
> > GroupedTotalExcl:
> >
>
Number(dgInvoiceListGrouped.dataProvider.getItemAt(j).GroupedTotalExcl.toString()),
> > GroupedTotalIncl:
> >
>
Number(dgInvoiceListGrouped.dataProvider.getItemAt(j).GroupedTotalIncl.toString())};
> > }
> > 
> > dgInvoiceListGrouped.dataProvider = [];
> > dgInvoiceListGrouped.dataProvider = GroupedArray;
> >
>




[flexcoders] Re: sort datagridcolumn on numeric field - use sortCompareFunction ?

2007-01-15 Thread amigo_fd
any ideas on how to do this with sortCompareFunction ?

--- In flexcoders@yahoogroups.com, "amigo_fd" <[EMAIL PROTECTED]> wrote:
>
> Hello, it looks like all data in a datagrid is treated as text. So if
> you sort a column with only numeric fields it is sorted on the value
> of the textual contect, instead of the numeric value, like this:
> 
> 1095
> 111
> 1276
> 144
> ...
> 
> I already converted my webservice-result to numbers at loading, but
> sorting keeps using text-value ... How to change this ?
> 
> dgInvoiceListGrouped.dataProvider = new XMLListCollection(x.children());
> var GroupedArray:Array = [];
>   
> for (var j:Number = 0; j < dgInvoiceList.dataProvider.length; j++) {  
> GroupedArray[j] = {Name:
> dgInvoiceListGrouped.dataProvider.getItemAt(j).Name.toString(),
>   Country:
> dgInvoiceListGrouped.dataProvider.getItemAt(j).Country.toString(),
>   GroupedTotalExcl:
>
Number(dgInvoiceListGrouped.dataProvider.getItemAt(j).GroupedTotalExcl.toString()),
>   GroupedTotalIncl:
>
Number(dgInvoiceListGrouped.dataProvider.getItemAt(j).GroupedTotalIncl.toString())};
> }
>   
> dgInvoiceListGrouped.dataProvider = [];
> dgInvoiceListGrouped.dataProvider = GroupedArray;
>