1 Reply Latest reply on May 8, 2009 6:06 AM by Gregory Lafrance

    Advanceddatagrid with grouping - how to sort?

    shaunperry

      Hi

       

      I have an advanced datagrid with a groupingfield. The data is passed from Coldfusion into the dataprovider in the correct order. For some reason the grid seems to change the row ordering. On googling this issue I found various notes that I need to resort the data once its in, but I m struggling to get it to work, can anyone help?

       

      Shaun

      private function initDG():void {
                          myGroupColl.source=testgrid.dataProvider;
                          var group:Grouping=new Grouping();
                          var gf:GroupingField=new GroupingField("groupName");
                          group.fields=[gf];
                          myGroupColl.grouping=group;                    
                          testgrid.dataProvider.sort = new Sort();
                          testgrid.dataProvider.sort.fields = [new SortField("groupName", true, false), new SortField("articleNumber", true, false)];                              
                          myGroupColl.refresh();
                          testgrid.dataProvider=myGroupColl;
                          testgrid.validateNow();
                          testgrid.expandAll();      
                     }
      
      <mx:AdvancedDataGrid width="878" height="100%" id="testgrid" editable="false" dataProvider="{dgData}" creationComplete="initDG();">
                                 <mx:columns>                                
                                     <mx:AdvancedDataGridColumn headerText="Article Number" dataField="articleNumber" width="188" editable="false" sortable="false" />
                                     <mx:AdvancedDataGridColumn headerText="Article Name" dataField="itemName" width="305" editable="false" sortable="false" />
                                     <mx:AdvancedDataGridColumn headerText="Colourway" dataField="colourway" width="275" editable="false" sortable="false" />
                                       <mx:AdvancedDataGridColumn editable="false" sortable="false" paddingLeft="1">
                                            <mx:itemRenderer>
                                                 <mx:Component>
                                                  <valueObjects:CartItemController/>
                                              </mx:Component>                                   
                                           </mx:itemRenderer>
                                       </mx:AdvancedDataGridColumn>
                                 </mx:columns>
                            </mx:AdvancedDataGrid>