1 Reply Latest reply on May 29, 2009 6:51 AM by *Prashant Shelke*

    How to do Groupby in AdvancedDatagrid using Remote Object

    sathiyabala Level 1

      Hai

       

           I need to know , how to make groupby in advanced datagrid using remote object.

       

       

          i have used "adhocClick.lastResult.deviceDetails.deviceDetail" like this to group by , but using ro how to make groupby in advanced datagrid

       

       

          can anyone help me.

       

       

      Thanks in Advance :-)

       

         

      <mx:HTTPService

       

      id="adhocClick" useProxy="false" url="../FlexAction.do?method=onTreeViewLoad" method="POST" fault="faultHandler(event)" result="resultValues(event, 'TREEVIEW')"/>

       

      private

       

       

      function adhocinvGroupHandler(fromVal:String):void {

       

       

      var i:int;

       

      var selectedTempArray:ArrayCollection = new ArrayCollection;

       

       

      if(fromVal != 'RESULT') {

      adhocinvgroupName.addItem(adhocgroupbyselect.selectedItem)

       

      if(adhocinvgroupName.length == 1) {

      adhocinvgroupName.addItemAt(

      "SELECT TO UNGROUP", 0);

      }

      adhocgroupBy.dataProvider = adhocinvgroupName;

       

      var selectedArray1:String =ArrayUtil.toArray(adhocgroupbyselect.dataProvider).toString();

       

      var selectedArray:Array = selectedArray1.split(',');

       

      for(var j:int = 0; j<selectedArray.length; j++) {

       

      if(selectedArray[j].toString().length > 0 && selectedArray[j] != adhocgroupbyselect.selectedItem) {

      selectedTempArray.addItem(selectedArray[j]);

      }

      }

      adhocgroupbyselect.selectedIndex = 0;

      selectedTempArray.refresh();

      adhocgroupbyselect.dataProvider = selectedTempArray;

      }

       

      var groupingCollection:GroupingCollection=new GroupingCollection();

       

      var grouping:Grouping=new Grouping();

       

      var groupingField:GroupingField;

      grouping.fields=

      new Array();

       

      for(i = 1; i < adhocinvgroupName.length; i++) {

      groupingField=

      new GroupingField(adhocinvgroupName[i]);

      groupingCollection.source=ArrayCollection(adhocClick.lastResult.deviceDetails.deviceDetail );

      grouping.fields.push(groupingField);

      groupingCollection.grouping=grouping

      }

      groupingCollection.refresh();

      adhocdetailgrid.dataProvider=groupingCollection;

      }