0 Replies Latest reply on Aug 18, 2010 6:21 AM by sunitha.ramachandran

    Hi,count and filtering in adg

    sunitha.ramachandran

      Hi,
      Please help me ,I have an issue with the count and the filterfunction using adg.I need to filter the repeatitions in Territory,show the correct count.Eg:Territory
      a,a,b,b.c.It should show the value as a
      b,c and the count should be 5.When I use the filter function I get the count as 3
      {
      override public function set dataProvider(value:Object):void
      { // super.dataProvider=value;

      super.dataProvider= groupFn(value);
      //Alert.show(“value==>”+groupFn(value));
      }
      [Bindable]
      public var myGroup:GroupingCollection;
      [Bindable]
      public var grouping1:Grouping ;
      [Bindable]
      var sumRow:SummaryRow;
      [Bindable]
      var grpfield:GroupingField;
      [Bindable]
      var sumField1:SummaryField;
      [Bindable]
      public var tmpAC:ArrayCollection;

      public function groupFn(val:Object):GroupingCollection {

      myGroup=new GroupingCollection();
      grouping1= new Grouping();
      sumRow= new SummaryRow();
      sumField1=new SummaryField(“Territory”,”COUNT”)

      tmpAC = val as ArrayCollection;
      tmpAC.filterFunction = deDupe;
      myGroup.source=tmpAC;

      grpfield=new GroupingField(“Region”);

      sumRow.summaryPlacement=”group”;

      //sumField1=new SummaryField(“Region”,”COUNT”)
      sumField1.label=”COUNT”;
      sumRow.fields=[sumField1];
      grpfield.summaries=[sumRow];
      grouping1.fields= [grpfield];

      myGroup.grouping=grouping1;
      myGroup.refresh();
      // this.invalidateList();

      return myGroup;

      }
      [Bindable]
      public var tempObj:Object = {};
      /* [Bindable]
      public static var Count:int=0 ;
      */
      public function deDupe(item:Object):Boolean {
      var retVal:Boolean = false;

      if (!tempObj.hasOwnProperty(item.Territory)) {
      mx.controls.Alert.show(“groupFn”)
      tempObj[item.Territory] = item;
      retVal = true ;
      //Count=Count+1;

      } /* lse if(retVal == true ) {

      Count=Count+1;
      } */
      // mx.controls.Alert.show(“Count”+Count);
      return retVal;
      }

      }
      }