Sorting grouped columns in AdvancedDatagrid

I am looking for a solution to sort all grouped quantities in advancedDatagrid. This should be the same behavior as clicking in the column header.

Please note: I'm not looking for a solution to sort the IN fields in a group. There is a working solution called compareFunction.

But I can’t sort the two lines in my picture by the Einnahmen column. Sorry for the German word. Do you have an idea? enter image description here

Thank. Franc

+3
source share
4 answers

If you want to run the application with sorted columns, you need to simulate the header by clicking on the create / dateprovider update.

Try the following:

<mx:AdvancedDataGrid id="adg"
  updateComplete="adg.dispatchEvent(new AdvancedDataGridEvent(AdvancedDataGridEvent.HEADER_RELEASE, false, true, 3, 'Einnahmen'))">
    <mx:columns>
        ...
        <mx:AdvancedDataGridColumn dataField="Einnahmen" sortDescending="true" />
    </mx:columns>
</mx:AdvancedDataGrid> 

, , .

+4

EDIT: , dataProvider ActionScript. Sort , .

AdvancedDataGrid set dataProvider . , () Tree, AdvancedDataGrid.

:

, "Einnahmen" ( , ), dataProvider , , .

.

[Bindable] public var MyDataList:ArrayCollection;
private var einnahmenSortField:SortField = new SortField("Einnahmen", true, false);
private var theSort:Sort = new Sort();

// Called after data is returned from the remote service call to sort the data
public function SetMyDataList(returnedList:ArrayCollection):void
{
  MyDataList = returnedList;

  if (theSort == null)
  {
    theSort = new Sort();
    theSort.fields = [einnahmenSortField];
  }

  MyDataList.sort = this.theSort;   
  MyDataList.refresh();
}

HierarchicalData AdvancedDataGrid, HierarchicalData AdvancedDataGrid :

var hd:HierarchicalData = new HierarchicalData(myDataList);
hd.childrenField = "MyChildField";
myAdvancedDataGrid.dataProvider = hd;
+1

'sortExpertMode = "true" AdvancedDataGrid? :

  <mx:AdvancedDataGrid height="318"
                     id="dataSetsDG"
                     allowMultipleSelection="false"
                     folderClosedIcon="{null}"
                     folderOpenIcon="{null}"
                     defaultLeafIcon="{null}"
                     left="28"
                     top="162"
                     rowCount="11"
                     width="70%"
                     displayItemsExpanded="true"
                     sortExpertMode="true">
0

" " AdvancedDataGrid. HierarchialData ArrayCollection, . ! , ActionScript .

Advanced datagrid

    public function createHierarchialResultVO(results:ArrayCollection):ArrayCollection
    {
        [ArrayElementType("ResultsVO")]
        var dpHierrarchy:ArrayCollection = new ArrayCollection();

        for each(var result:Result in results)
        {
            var resultVO:ResultsVO= new ResultsVO();
            resultVO.resultName = result.resultName;
            resultVO.runDate = result.runDate.toString();
            resultVO.type="header";

            var childrens:ArrayCollection = new ArrayCollection();
            for each(var processDetails:ProcessDetails in result.details)
            {
                var children:ResultsVO= new ResultsVO();
                children.files =result.fileCount;
                children.status=result.status;
                children.type="result";
            }
            resultVO.children =children;
            dpHierrarchy.addItem(resultVO);
        }
        return dpHierrarchy;            
    }
0

Source: https://habr.com/ru/post/1789247/


All Articles