패키지 | mx.collections |
클래스 | public class SortField |
상속 | SortField EventDispatcher Object |
구현 | ISortField |
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Flex 4.5(으)로 시작하는 경우 이 클래스 대신 spark.collections.SortField 클래스를 사용하는 것이 좋습니다. |
Provides the sorting information required to establish a sort on a field or property in a collection view. The SortField class is meant to be used with the Sort class. Typically the sort is defined for collections of complex items, that is items in which the sort is performed on properties of those objects. As in the following example:
var col:ICollectionView = new ArrayCollection();
col.addItem({first:"Anders", last:"Dickerson"});
var sort:Sort = new Sort();
sort.fields = [new SortField("first", true)];
col.sort = sort;
There are situations in which the collection contains simple items, like
String
, Date
, Boolean
, etc.
In this case, sorting should be applied to the simple type directly.
When constructing a sort for this situation only a single sort field is
required and should not have a name
specified.
For example:
var col:ICollectionView = new ArrayCollection();
col.addItem("California");
col.addItem("Arizona");
var sort:Sort = new Sort();
sort.fields = [new SortField(null, true)];
col.sort = sort;
By default the comparison provided by the SortField class does
not provide correct language specific
sorting for strings. For this type of sorting please see the
spark.collections.Sort
and
spark.collections.SortField
classes.
The <mx:SortField>
tag has the following attributes:
<mx:SortField Properties caseInsensitive="false" compareFunction="Internal compare function" descending="false" name="null" numeric="null" />
관련 API 요소
속성 | 정의 주체 | ||
---|---|---|---|
arraySortOnOptions : int [읽기 전용]
This helper property is used internally by the findItem()
and sort() methods. | SortField | ||
caseInsensitive : Boolean
Specifies whether the sort for this field should be case insensitive. | SortField | ||
compareFunction : Function
The function that compares two items during a sort of items for the
associated collection. | SortField | ||
constructor : Object
지정된 객체 인스턴스의 클래스 객체 또는 생성자 함수에 대한 참조입니다. | Object | ||
descending : Boolean
Specifies whether this field should be sorted in descending
order. | SortField | ||
name : String
The name of the field to be sorted. | SortField | ||
numeric : Object
Specifies that if the field being sorted contains numeric
(number/int/uint) values, or string representations of numeric values,
the comparator use a numeric comparison. | SortField | ||
usingCustomCompareFunction : Boolean [읽기 전용]
True if this ISortField uses a custom comparator function. | SortField |
메서드 | 정의 주체 | ||
---|---|---|---|
SortField(name:String = null, caseInsensitive:Boolean = false, descending:Boolean = false, numeric:Object = null)
Constructor. | SortField | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
리스너에서 이벤트 알림을 받을 수 있도록 EventDispatcher 객체에 이벤트 리스너 객체를 등록합니다. | EventDispatcher | ||
이벤트를 이벤트 흐름으로 전달합니다. | EventDispatcher | ||
EventDispatcher 객체에 특정 유형의 이벤트에 대한 리스너가 등록되어 있는지 여부를 확인합니다. | EventDispatcher | ||
지정된 속성이 객체에 정의되어 있는지 여부를 나타냅니다. | Object | ||
A helper function called by the Sort class to set the
default comparison function to perform a comparison based on
one of three things: whether or not a custom compare function has
been set, the data type for the specified field or the the value of the
numeric property. | SortField | ||
Object 클래스의 인스턴스가 매개 변수로 지정된 객체의 프로토타입 체인에 있는지 여부를 나타냅니다. | Object | ||
지정된 속성이 존재하고 열거 가능한지 여부를 나타냅니다. | Object | ||
EventDispatcher 객체에서 리스너를 제거합니다. | EventDispatcher | ||
Reverse the criteria for this sort field. | SortField | ||
루프 작업에서 동적 속성을 사용할 수 있는지 여부를 설정합니다. | Object | ||
로캘별 규칙에 따라 서식이 지정된 이 객체의 문자열 표현을 반환합니다. | Object | ||
지정된 객체의 문자열 표현을 반환합니다. | Object | ||
지정된 객체의 프리미티브 값을 반환합니다. | Object | ||
이 EventDispatcher 객체 또는 조상 객체에 지정한 이벤트 유형에 대한 이벤트 리스너가 등록되어 있는지 여부를 확인합니다. | EventDispatcher |
arraySortOnOptions | 속성 |
arraySortOnOptions:int
[읽기 전용] 언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
This helper property is used internally by the findItem()
and sort()
methods. Other uses of this property are not
supported.
Returns -1 if this ISortField shouldn't be used by the Sort
class to sort the field (there is no compareFunction or no name). Otherwise, returns a bitmask of sort options..
구현
public function get arraySortOnOptions():int
caseInsensitive | 속성 |
caseInsensitive:Boolean
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Specifies whether the sort for this field should be case insensitive.
기본값: false.
이 속성은 데이터 바인딩에 대한 소스로 사용할 수 있습니다. 이 속성을 수정하면 caseInsensitiveChanged
이벤트를 전달합니다.
구현
public function get caseInsensitive():Boolean
public function set caseInsensitive(value:Boolean):void
compareFunction | 속성 |
compareFunction:Function
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
The function that compares two items during a sort of items for the
associated collection. If you specify a compareFunction
property in an ISort object, Flex ignores any
compareFunction
properties of the ISort's SortField
objects.
The compare function must have the following signature:
function myCompare(a:Object, b:Object):int
This function must return the following values:
- -1, if
a
should appear beforeb
in the sorted sequence - 0, if
a
equalsb
- 1, if
a
should appear afterb
in the sorted sequence
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 need a custom comparison algorithm. This is normally only the case if a calculated field is used in a display.
Note if you need, language specific sorting then consider using thespark.collections.SortField
class.
구현
public function get compareFunction():Function
public function set compareFunction(value:Function):void
관련 API 요소
descending | 속성 |
descending:Boolean
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Specifies whether this field should be sorted in descending order.
The default value is false
(ascending).
이 속성은 데이터 바인딩에 대한 소스로 사용할 수 있습니다. 이 속성을 수정하면 descendingChanged
이벤트를 전달합니다.
구현
public function get descending():Boolean
public function set descending(value:Boolean):void
name | 속성 |
numeric | 속성 |
numeric:Object
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Specifies that if the field being sorted contains numeric
(number/int/uint
) values, or string representations of numeric values,
the comparator use a numeric comparison.
This property is used by SortField
class in case custom compare
function is not provided.
If this property is true
, the built-in numeric compare
function is used. Each of data items is cast to a
Number()
function before the comparison.
If this property is false
, the built-in string compare
function is used. Each of data items is cast to a
String()
function before the comparison.
If this property is null
, the first data item
is introspected to see if it is a number or string and the sort
proceeds based on that introspection.
기본값: null.
이 속성은 데이터 바인딩에 대한 소스로 사용할 수 있습니다. 이 속성을 수정하면 numericChanged
이벤트를 전달합니다.
구현
public function get numeric():Object
public function set numeric(value:Object):void
usingCustomCompareFunction | 속성 |
SortField | () | 생성자 |
public function SortField(name:String = null, caseInsensitive:Boolean = false, descending:Boolean = false, numeric:Object = null)
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Constructor.
매개 변수name:String (default = null ) — The name of the property that this field uses for
comparison.
If the object is a simple type, pass null .
| |
caseInsensitive:Boolean (default = false ) — When sorting strings, tells the comparator
whether to ignore the case of the values.
| |
descending:Boolean (default = false ) — Tells the comparator whether to arrange items in
descending order.
| |
numeric:Object (default = null ) — Tells the comparator whether to compare sort items as
numbers, instead of alphabetically.
|
initializeDefaultCompareFunction | () | 메서드 |
public function initializeDefaultCompareFunction(obj:Object):void
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
A helper function called by the Sort
class to set the
default comparison function to perform a comparison based on
one of three things: whether or not a custom compare function has
been set, the data type for the specified field or the the value of the
numeric property. If the the numeric
property is true,
then a numeric comparison will be performed when sorting.
매개 변수
obj:Object — The object that contains the data. If the field name has
been set with the name property, then the name will be used to access
the data value from this object. Otherwise the object itself will
be used as the data value.
|
reverse | () | 메서드 |
public function reverse():void
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Reverse the criteria for this sort field. If the field was sorted in descending order, for example, sort it in ascending order.
NOTE: An ICollectionView
does not automatically
update when the ISortFields
are modified; call its
refresh()
method to update the view.
Tue Jun 12 2018, 03:17 PM Z