3 Replies Latest reply on Aug 16, 2010 6:42 AM by bindu84

    summary field operation

    bindu84

      I am using the summary field for operation (Max/Min) for date type data but it is showing NAN beacuse summary field opration take only numeric value.

       

      So how to use that for date type value

        • 1. Re: summary field operation
          rootsounds Level 4

          What is "data type value"?

          • 2. Re: summary field operation
            bindu84 Level 1

            data is of date Type.

             

            16/02/1984

            16/01/1986

            16/03/2005

            • 3. Re: summary field operation
              bindu84 Level 1

              <?xml version="1.0" encoding="utf-8" ?>

               

               

              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

              layout="

              vertical" initialize="init()">

               

               

              <mx:Script>

              <![CDATA[

               

              import mx.utils.ObjectUtil;

               

              import mx.formatters.DateFormatter;

               

              import mx.collections.ArrayCollection;

               

              import mx.events.AdvancedDataGridEvent;

               

              import mx.events.DataGridEvent;

               

              import mx.events.ListEvent;

               

              import mx.controls.List;

               

              import mx.events.ItemClickEvent;

               

              import mx.collections.IViewCursor;

               

              import mx.controls.Alert;

               

              import mx.controls.TextInput;

               

              [

              Bindable]public var num1:Number;

              [

              Bindable]public var num2:Number;

              [

              Bindable]public var num3:Number = 1;

              [

              Bindable]public var num4:Number = 2;

              [

              Bindable]public var num5:Number = 3;

              [

              Bindable]public var num6:Number = 4;

               

               

              public var newVal:String;

              [

              Bindable]

               

              public var myArrayCollection:ArrayCollection;

               

               

              private function func(itr:IViewCursor,field:String,

              str:String=

              null):Object

              {

              myArrayCollection.refresh();

               

              var sum:Number=0

               

              var max:Number;

               

              var dateA:Date;

               

              var dateB:Date;

               

              var res:Number;

               

              while(!itr.afterLast)

              {

               

              //trace(itr.current)

               

               

              var value = itr.current.Date;

              dateB =

              new Date(String(value));

              res = ObjectUtil.dateCompare(dateA, dateB);

               

              if(dateA == null)dateA = dateB ;

               

              else if(res == 1) dateA = dateB ;

               

              else if(res == -1)dateA = dateA;

              itr.moveNext()

              }

               

              var dateFormatterStr:DateFormatter = new DateFormatter();

              dateFormatterStr.formatString =

              "MM-DD-YYYY";

               

              var ty = dateFormatterStr.format(dateA);

               

              return ty;

              }

               

               

              public function init():void {

              myArrayCollection =

              new ArrayCollection(arr);

              }

               

               

              private function getCellInfo(event:AdvancedDataGridEvent):void {

               

              myArrayCollection.refresh();

              summaryField.summaryFunction=func;

              }

               

               

              ]]>

               

              </mx:Script>

               

              <mx:Array id="arr">

               

              <mx:Object From="a1" Subject="a" Date="12/08/06" Profit="1"/>

               

              <mx:Object From="b1" Subject="b" Date="12/08/06" Profit="2"/>

               

               

              <mx:Object From="c1" Subject="c" Date="12/08/06" Profit="3"/>

               

              <mx:Object From="d1" Subject="d" Date="12/08/06" Profit="4"/>

               

               

              </mx:Array>

               

              <mx:AdvancedDataGrid id="adg" displayItemsExpanded="true"

              creationComplete="gc.refresh();"

              height="

              300" editable="true" itemEditEnd="getCellInfo(event);">

               

              <mx:dataProvider>

               

              <mx:GroupingCollection id="gc" source="{myArrayCollection}">

               

              <mx:Grouping>

               

              <mx:GroupingField name="From">

               

              <mx:SummaryRow summaryPlacement="last">

               

              <mx:fields>

               

              <mx:SummaryField dataField="Profit" label="summary"

              summaryFunction="

              func" id="summaryField"/>

               

              </mx:fields>

               

              </mx:SummaryRow>

               

              </mx:GroupingField>

               

              </mx:Grouping>

               

              </mx:GroupingCollection>

               

              </mx:dataProvider>

               

              <mx:columns>

               

              <mx:AdvancedDataGridColumn id="col1" dataField="From"/>

               

              <mx:AdvancedDataGridColumn dataField="Subject" />

               

              <mx:AdvancedDataGridColumn dataField="Date" />

               

              <mx:AdvancedDataGridColumn dataField="CC" />

               

              <mx:AdvancedDataGridColumn dataField="Profit"/>

               

              </mx:columns>

               

               

              </mx:AdvancedDataGrid>

               

              </mx:Application>

               

              n that i want to apply minimum operation on date , How to implement it ,