適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: 從伺服器擷取資料...
從伺服器擷取資料...
mx.collections 

Grouping  - AS3 Flex

套件mx.collections
類別public class Grouping
繼承Grouping Inheritance Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The Grouping class defines the fields in the data provider of the AdvancedDataGrid control used to group data. You use this class to create groups when the input data to the AdvancedDataGrid control has a flat structure.

To populate the AdvancedDataGrid control with grouped data, you create an instance of the GroupingCollection class from your flat data, and then pass that GroupingCollection instance to the data provider of the AdvancedDataGrid control. To specify the grouping fields of your flat data, you pass a Grouping instance to the GroupingCollection.grouping property. The Grouping instance contains an Array of GroupingField instances, one per grouping field.

The following example uses the Grouping class to define two grouping fields: Region and Territory.

  <mx:AdvancedDataGrid id="myADG"    
    <mx:dataProvider> 
      <mx:GroupingCollection id="gc" source="{dpFlat}"> 
        <mx:grouping> 
          <mx:Grouping> 
            <mx:GroupingField name="Region"/> 
            <mx:GroupingField name="Territory"/> 
          </mx:Grouping> 
        </mx:grouping> 
      </mx:GroupingCollection> 
    </mx:dataProvider>  
     
    <mx:columns> 
      <mx:AdvancedDataGridColumn dataField="Region"/> 
      <mx:AdvancedDataGridColumn dataField="Territory"/> 
      <mx:AdvancedDataGridColumn dataField="Territory_Rep"/> 
      <mx:AdvancedDataGridColumn dataField="Actual"/> 
      <mx:AdvancedDataGridColumn dataField="Estimate"/> 
    </mx:columns> 
  </mx:AdvancedDataGrid>
  

MXML 語法expanded隱藏 MXML 語法
The <mx.Grouping> tag defines the following tag attributes:

  <mx:Grouping
  Properties 
    compareFunction="No default"
    fields="null"
    groupingObjectFunction="No default"
    label="GroupLabel"
  />
  

預設 MXML 屬性fields

相關 API 元素



公用屬性
 屬性定義自
  compareFunction : Function
The method used to compare items when sorting.
Grouping
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
  fields : Array
An Array of GroupingField objects that specifies the fields used to group the data.
Grouping
  groupingObjectFunction : Function
A callback function to run on each group node to determine the grouping object.
Grouping
  label : String = "GroupLabel"
The name of the field added to the flat data to create the hierarchy.
Grouping
公用方法
 方法定義自
  
Constructor.
Grouping
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
屬性詳細資訊

compareFunction

屬性
compareFunction:Function

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The method used to compare items when sorting. If you specify this property, Flex ignores any compareFunction properties that you specify in the SortField objects that you use in this class.

The compare function must have the following signature:

         function [name](a:Object, b:Object, fields:Array=null):int

This function must return the following:

  • -1, if a should appear before b in the sorted sequence.
  • 0, if a equals b.
  • 1, if a should appear after b in the sorted sequence.

To return to the internal comparison function, set this value to null.

The fields Array specifies the object fields to compare. Typically, the algorithm will compare properties until the field list is exhausted or a non-zero value can be returned. For example:

        function myCompare(a:Object, b:Object, fields:Array=null):int
        {
            var result:int = 0;
            var i:int = 0;
            var propList:Array = fields ? fields : internalPropList;
            var len:int = propList.length;
            var propName:String;
            while (result == 0 && (i < len))
            {
                propName = propList[i];
                result = compareValues(a[propName], b[propName]);
                i++;
            }
            return result;
        }
     
        function compareValues(a:Object, b:Object):int
        {
            if (a == null && b == null)
                return 0;
     
            if (a == null)
              return 1;
     
            if (b == null)
               return -1;
     
            if (a < b)
                return -1;
     
            if (a > b)
                return 1;
     
            return 0;
        }

The default value is an internal compare function that can perform a string, numeric, or date comparison in ascending or descending order, with case-sensitive or case-insensitive string comparisons. Specify your own function only if you need a custom comparison algorithm. This is normally only the case if a calculated field is used in a display.

Alternatively, you can specify separate compare functions for each sort field by using the SortField class compare property. This way you can use the default comparison for some fields and a custom comparison for others.



實作
    public function get compareFunction():Function
    public function set compareFunction(value:Function):void

fields

屬性 
fields:Array

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

An Array of GroupingField objects that specifies the fields used to group the data. The order of the GroupingField objects in the Array determines field priority order when sorting.

預設值為 null。



實作
    public function get fields():Array
    public function set fields(value:Array):void

相關 API 元素

groupingObjectFunction

屬性 
public var groupingObjectFunction:Function

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

A callback function to run on each group node to determine the grouping object. By default, a new Object will be created for group nodes.

You can supply a groupingObjectFunction that provides the appropriate Object for group nodes.

The method signature is:

      myGroupObjectFunction(label:String):Object

Where label contains the value that will be shown for that group node. The function returns an Object which will be used for group nodes.

For example, a groupingObjectFunction which returns an Object containing a "name" property with value as "Bob" can be written as -
      private function groupObjFunction(label:String):Object
      {
          var obj:Object = {};
          obj.name = "Bob";
     
          return obj;
      }
      

label

屬性 
public var label:String = "GroupLabel"

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The name of the field added to the flat data to create the hierarchy. The value of the top nodes (nodes representing the group fields) in every group will be represented by this property. Use this property to specify a different name.

預設值為 GroupLabel。

建構函式詳細資料

Grouping

()建構函式
public function Grouping()

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Constructor.





[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。