5 Replies Latest reply on Jan 30, 2007 8:38 AM by dimival

    Why am I getting NaN with a calculated DG column?

    Level 7
      Hi-
      I am trying to use a labelfunction to get a simple calculated data grid
      column but I keep getting NaN. It seems like it should be a number to me -
      code snippets:

      public function calculateValue(item:Object, column:DataGridColumn):String {
      var sum:Number = dataProvider.price * dataProvider.quantity;
      return isNaN(sum) ? "Not A Number" : PriceFormatter.format(sum.toString());
      }

      <mx:CurrencyFormatter id="PriceFormatter"
      precision="2"
      decimalSeparatorTo="."
      currencySymbol=""
      alignSymbol="left"
      />

      <mx:DataGrid id="dgSymbolRequest" dataProvider="{dataProvider}" left="22"
      top="86" bottom="271" right="0">
      <mx:columns>
      <mx:DataGridColumn headerText="Last Price" dataField="price" width="90"
      itemRenderer="stockPriceItemRenderer"/>
      <mx:DataGridColumn headerText="Quantity" dataField="quantity" width="60"/>
      <mx:DataGridColumn headerText="Value" width="90"
      labelFunction="calculateValue"/>
      </mx:columns>
      </mx:DataGrid>


      The data is coming from a MySQL database and both the price and quantity
      columns are set as Double. Any help as to why this is happening would be
      appreciated. Thank you,
      -Dan