1 Reply Latest reply on Oct 24, 2008 7:54 AM by Karl_Sigiscar_1971

    AdvancedDatagrid with a summary row

    Karl_Sigiscar_1971 Level 3
      Hello,

      I have an AdvancedDatagrid with two grouping fields in a summary row.

      Everything works fine when there is no labelFunction associated with it.
      But as soon as I specify a labelFunction, the summary row fields are empty. I need a labelFunction to format dates and numbers.

      How to write a proper labelFunction for an AdvancedDatagrid with a summary row ?

      Regards,
      Karl.
        • 1. AdvancedDatagrid with a summary row
          Karl_Sigiscar_1971 Level 3
          Okay, I figured it out.

          Now, I have two label functions set at the AdvancedDataGridColumn level for the summary row fields and one labelFunction set at the AdvancedDataGrid level for all the other fields.

          <mx:AdvancedDataGridColumn id="amountTotal" dataField="sumAmount" labelFunction="sumAmountLabelFunction" />

          <mx:AdvancedDataGridColumn id="collectedTotal" dataField="sumCollected" labelFunction="sumCollectedLabelFunction" />

          In order to avoid a null pointer exception on the sumAmount and sumCollected fields in the label function, I use the hasOwnProperty() method to check before access. Otherwise, this exception will happen while expanding the tree.

          private function sumAmountLabelFunction(item:Object, column:AdvancedDataGridColumn):String
          {
          if(item.hasOwnProperty("sumAmount"))
          return this.numberFormatter.format(item.sumAmount);

          return "";
          }

          private function sumCollectedLabelFunction(item:Object, column:AdvancedDataGridColumn):String
          {
          if(item.hasOwnProperty("sumCollected"))
          return this.numberFormatter.format(item.sumCollected);

          return "";
          }