0 Replies Latest reply on Sep 24, 2008 10:30 AM by aKeychian

    Error in groups advancedDataGrid

      I am developing an application with backend on .net.
      I'm trying to pool data through ObjCliente.Nombre tag with the following code, but repeated sample groups but with different content, although I try to sort the data, the last function that is executed is groupFunc, which takes random elements the grid, and start by grouping objects, but only the row. For example, I have 4 ObjectProxy in ArrayCollection that have the following information in ObjCliente.Nombre:

      ObjCliente.Nombre 1 = "foo"
      ObjCliente.Nombre 2 = "raul"
      ObjCliente.Nombre 3 = "foo"
      ObjCliente.Nombre 4 = "foo"

      This would generate 3 clusters, the first "foo", the second "raul" and the third "foo"

      If anyone can help me so kindly.

      Xml and code here:
      Attach Code

      <Nombre>Azul Paraiso2 2</Nombre>
      <Descripcion />
      - <ObjCliente>

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*"
      width="100%" height="100%">

      import mx.collections.SortField;
      import mx.collections.Sort;
      import mx.collections.GroupingCollection;
      import mx.collections.Grouping;
      import mx.collections.GroupingField;
      import mx.rpc.events.ResultEvent;
      import mx.collections.ArrayCollection;

      [Bindable]private var myData:ArrayCollection;
      [Bindable]public var myGColl:GroupingCollection = new GroupingCollection();
      private var myGrp:Grouping = new Grouping();

      private function getData():void

      private function resultHandler(event:ResultEvent):void
      myData = event.result as ArrayCollection;
      var ordenaLista:Sort = new Sort();
      ordenaLista.compareFunction =sortByClientes;
      myData.sort = ordenaLista

      private function groupFunc(item:Object, field:GroupingField):String
      // display field2 as the label of the group
      return item.ObjCliente.Nombre;

      private function initDG():void {

      // Initialize the GroupingCollection instance.
      myGColl.source = myData;

      // The Grouping instance defines the grouping fields
      // in the collection, and the order of the groups
      // in the hierarchy.
      var gf:GroupingField = new GroupingField("Cliente");
      gf.groupingFunction = groupFunc;
      var gf1:GroupingField = new GroupingField("Nombre");

      // The grouping property contains a Grouping instance.
      myGColl.grouping = myGrp;

      // Specify the GroupedCollection as the data provider for
      // the AdvancedDataGrid control.

      // Refresh the display.

      private function sortByClientes(obj1:Object, obj2:Object,fields:Array = null):int
      var value1:String = obj1.ObjCliente.Nombre;
      var value2:String = obj2.ObjCliente.Nombre;

      if(value1 < value2) {
      return -1;
      else if(value1 > value2){
      return 1;
      else {
      return 0;


      <mx:WebService id="myWS"
      wsdl=" http://localhost/XlineProjectTools/WebServices/Proyectos.asmx?WSDL"
      result="resultHandler(event)" />

      <mx:AdvancedDataGrid id="dgProyectos" width="100%" height="100%" creationComplete="initDG();" sortableColumns="true">
      <mx:AdvancedDataGridColumn headerText="Nombre" dataField="Nombre" />
      <mx:AdvancedDataGridColumn headerText="Nombre2" dataField="Nombre" />
      <mx:AdvancedDataGridColumn headerText="Descripcion" dataField="Descripcion" />