1 Reply Latest reply on Feb 3, 2007 11:24 AM by FrankAtcomm

    sort datagridcolumn on numeric field

    FrankAtcomm
      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 ? Or do I have to build a custom function for this (with sortCompareFunction) ?

      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;