Pacote | mx.collections |
Classe | public class ListCollectionView |
Herança | ListCollectionView Proxy |
Implementações | ICollectionView, IList, IMXMLObject |
Subclasses | ArrayCollection, XMLListCollection |
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
ICollectionView
interface to an object that conforms to the
IList
interface. As a result, you can pass an object of this class
to anything that requires an IList
or ICollectionView
.
This class also lets you use [ ] array notation
to access the getItemAt()
and setItemAt()
methods.
If you use code such as myListCollectionView[index]
Flex calls the myListCollectionView
object's
getItemAt()
or setItemAt()
method.
The <mx:ListCollectionView>
has the following attributes,
which all of its subclasses inherit:
<mx:ListCollectionView Properties filterFunction="null" list="null" sort="null" Events collectionChange="No default" />
Propriedade | Definido por | ||
---|---|---|---|
filterFunction : Function
A function that the view will use to eliminate items that do not
match the function's criteria. | ListCollectionView | ||
length : int [somente leitura]
The number of items in this view. | ListCollectionView | ||
list : IList
The IList that this collection view wraps. | ListCollectionView | ||
sort : ISort
The ISort that will be applied to the ICollectionView. | ListCollectionView |
Propriedade | Definido por | ||
---|---|---|---|
localIndex : Array
When the view is sorted or filtered the localIndex property
contains an array of items in the sorted or filtered (ordered, reduced)
view, in the sorted order. | ListCollectionView |
Método | Definido por | ||
---|---|---|---|
ListCollectionView(list:IList = null)
The ListCollectionView constructor. | ListCollectionView | ||
Adds a list of items to the current list, placing them at the end of
the list in the order they are passed. | ListCollectionView | ||
Adds a list of items to the current list, placing them at the position
index passed in to the function. | ListCollectionView | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event. | ListCollectionView | ||
Adds the specified item to the end of the list. | ListCollectionView | ||
Adds the item at the specified index. | ListCollectionView | ||
Returns whether the view contains the specified object. | ListCollectionView | ||
Creates a new IViewCursor that works with this view. | ListCollectionView | ||
Prevents changes to the collection itself and items within the
collection from being dispatched by the view. | ListCollectionView | ||
Dispatches an event into the event flow. | ListCollectionView | ||
Enables auto-updating. | ListCollectionView | ||
Gets the item at the specified index. | ListCollectionView | ||
Returns the index of the item if it is in the list such that
getItemAt(index) == item. | ListCollectionView | ||
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event. | ListCollectionView | ||
Called automatically by the MXML compiler when the ListCollectionView
is created using an MXML tag. | ListCollectionView | ||
itemUpdated(item:Object, property:Object = null, oldValue:Object = null, newValue:Object = null):void
Notifies the view that an item has been updated. | ListCollectionView | ||
Applies the sort and filter to the view. | ListCollectionView | ||
Remove all items from the list. | ListCollectionView | ||
Removes a listener from the EventDispatcher object. | ListCollectionView | ||
Removes the item at the specified index and returns it. | ListCollectionView | ||
Places the item at the specified index. | ListCollectionView | ||
Returns an Array that is populated in the same order as the IList
implementation. | ListCollectionView | ||
Prints the contents of this view to a string and returns it. | ListCollectionView | ||
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | ListCollectionView |
Evento | Resumo | Definido por | ||
---|---|---|---|---|
Dispatched when the ICollectionView has been updated in some way. | ListCollectionView |
filterFunction | propriedade |
filterFunction:Function
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
A function that the view will use to eliminate items that do not match the function's criteria. A filterFunction is expected to have the following signature:
f(item:Object):Booleanwhere the return value is
true
if the specified item
should remain in the view.
If a filter is unsupported, Flex throws an error when accessing
this property.
You must call refresh()
after setting the
filterFunction
property for the view to update.
Note: The Flex implementations of ICollectionView retrieve all items from a remote location before executing the filter function. If you use paging, apply the filter to the remote collection before you retrieve the data.
Essa propriedade pode ser usada como a origem para o vínculo de dados. Quando essa propriedade é modificada, ela despacha o evento filterFunctionChanged
.
Implementação
public function get filterFunction():Function
public function set filterFunction(value:Function):void
Elementos da API relacionados
length | propriedade |
length:int
[somente leitura] Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
The number of items in this view. 0 means no items, while -1 means that the length is unknown.
Essa propriedade pode ser usada como a origem para o vínculo de dados. Quando essa propriedade é modificada, ela despacha o evento collectionChange
.
Implementação
public function get length():int
list | propriedade |
list:IList
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
The IList that this collection view wraps.
Essa propriedade pode ser usada como a origem para o vínculo de dados. Quando essa propriedade é modificada, ela despacha o evento listChanged
.
Implementação
public function get list():IList
public function set list(value:IList):void
localIndex | propriedade |
protected var localIndex:Array
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
When the view is sorted or filtered the localIndex
property
contains an array of items in the sorted or filtered (ordered, reduced)
view, in the sorted order.
The ListCollectionView class uses this property to access the items in
the view.
The localIndex
property should never contain anything
that is not in the source, but may not have everything in the source.
This property is null
when there is no sort.
sort | propriedade |
sort:ISort
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
The ISort that will be applied to the ICollectionView.
Setting the sort does not automatically refresh the view,
so you must call the refresh()
method
after setting this property.
If sort is unsupported an error will be thrown when accessing
this property.
Note: The Flex implementations of ICollectionView retrieve all items from a remote location before executing a sort. If you use paging with a sorted list, apply the sort to the remote collection before you retrieve the data.
Essa propriedade pode ser usada como a origem para o vínculo de dados. Quando essa propriedade é modificada, ela despacha o evento sortChanged
.
Implementação
public function get sort():ISort
public function set sort(value:ISort):void
Elementos da API relacionados
ListCollectionView | () | Construtor |
addAll | () | método |
public function addAll(addList:IList):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Adds a list of items to the current list, placing them at the end of the list in the order they are passed.
Parâmetros
addList:IList — The list of items to add to the current list
|
addAllAt | () | método |
public function addAllAt(addList:IList, index:int):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Adds a list of items to the current list, placing them at the position index passed in to the function. The items are placed at the index location and placed in the order they are recieved.
Parâmetros
addList:IList — The list of items to add to the current list
| |
index:int — The location of the current list to place the new items.
|
Lança
RangeError — if index is less than 0 or greater than the length of the list.
|
addEventListener | () | método |
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority.
After you successfully register an event listener, you cannot change its priority
through additional calls to addEventListener()
. To change a listener's priority, you
must first call removeEventListener()
. Then you can register the listener again with the new
priority level.
After the listener is registered, subsequent calls to
addEventListener()
with a different value for either type
or useCapture
result in the
creation of a separate listener registration. For example, if you first register a
listener with useCapture
set to true
, it listens only during the capture phase. If you
call addEventListener()
again using the same listener object, but with useCapture
set to
false
, you have two separate listeners: one that listens during the capture phase, and
another that listens during the target and bubbling phases.
You cannot register an event listener for only the target phase or the bubbling phase. Those phases are coupled during registration because bubbling applies only to the ancestors of the target node.
When you no longer need an event listener, remove it by calling EventDispatcher.removeEventListener()
; otherwise, memory problems might result. Objects
with registered event listeners are not automatically removed from memory because the
garbage collector does not remove objects that still have references.
Copying an EventDispatcher instance does not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached to it move along with it.
If the event listener is being registered on a node while an event is also being processed on this node, the event listener is not triggered during the current phase but may be triggered during a later phase in the event flow, such as the bubbling phase.
If an event listener is removed from a node while an event is being processed on the node, it is still triggered by the current actions. After it is removed, the event listener is never invoked again (unless it is registered again for future processing).
Parâmetros
type:String — The type of event.
| |
listener:Function — The listener function that processes the event. This function must accept an event object
as its only parameter and must return nothing, as this example shows:
| |
useCapture:Boolean (default = false ) — Determines whether the listener works in the capture phase or the target
and bubbling phases. If useCapture is set to true , the
listener processes the event only during the capture phase and not in the target or
bubbling phase. If useCapture is false , the listener processes the event only
during the target or bubbling phase. To listen for the event in all three phases, call
addEventListener() twice, once with useCapture set to true ,
then again with useCapture set to false .
| |
priority:int (default = 0 ) — The priority level of the event listener. Priorities are designated by a 32-bit integer. The higher the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.
| |
useWeakReference:Boolean (default = false ) — Determines whether the reference to the listener is strong or weak. A strong
reference (the default) prevents your listener from being garbage-collected. A weak
reference does not. Class-level member functions are not subject to garbage
collection, so you can set |
addItem | () | método |
addItemAt | () | método |
public function addItemAt(item:Object, index:int):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Adds the item at the specified index. The index of any item greater than the index of the added item is increased by one. If the the specified index is less than zero or greater than the length of the list, a RangeError is thrown.
Parâmetros
item:Object — The item to place at the index.
| |
index:int — The index at which to place the item.
|
contains | () | método |
public function contains(item:Object):Boolean
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Returns whether the view contains the specified object.
Unlike the IViewCursor.findxxx
methods,
this search is succesful only if it finds an item that exactly
matches the parameter.
If the view has a filter applied to it this method may return
false
even if the underlying collection
does contain the item.
Parâmetros
item:Object — The object to look for.
|
Boolean — true if the ICollectionView, after applying any filter,
contains the item; false otherwise.
|
Elementos da API relacionados
createCursor | () | método |
public function createCursor():IViewCursor
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Creates a new IViewCursor that works with this view.
RetornaIViewCursor — A new IViewCursor implementation.
|
disableAutoUpdate | () | método |
public function disableAutoUpdate():void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Prevents changes to the collection itself and items within the
collection from being dispatched by the view.
Also prevents the view from updating the positions of items
if the positions change in the collection.
The changes will be queued and dispatched appropriately
after enableAutoUpdate
is called.
If more events than updates to a single item occur,
the view may end up resetting.
The disableAutoUpdate
method acts cumulatively;
the same number of calls to enableAutoUpdate
are required for the view to dispatch events and refresh.
Note that disableAutoUpdate
only affects the
individual view; edits may be detected on an individual
basis by other views.
Elementos da API relacionados
dispatchEvent | () | método |
public function dispatchEvent(event:Event):Boolean
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Dispatches an event into the event flow. The event target is the
EventDispatcher object upon which dispatchEvent()
is called.
Parâmetros
event:Event — The event object dispatched into the event flow.
|
Boolean — A value of true unless preventDefault() is called on the event,
in which case it returns false .
|
enableAutoUpdate | () | método |
public function enableAutoUpdate():void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Enables auto-updating.
See disableAutoUpdate
for more information.
Elementos da API relacionados
getItemAt | () | método |
public function getItemAt(index:int, prefetch:int = 0):Object
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Gets the item at the specified index.
Parâmetros
index:int — The index in the list from which to retrieve the item.
| |
prefetch:int (default = 0 ) — An int indicating both the direction
and number of items to fetch during the request if the item is
not local.
|
Object — The item at that index, or null if there is none.
|
getItemIndex | () | método |
public function getItemIndex(item:Object):int
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Returns the index of the item if it is in the list such that getItemAt(index) == item.
Note: unlike IViewCursor.findxxx()
methods,
The getItemIndex()
method cannot take a parameter with
only a subset of the fields in the item being serched for;
this method always searches for an item that exactly matches
the input parameter.
Parâmetros
item:Object — The item to find.
|
int — The index of the item, or -1 if the item is not in the list.
|
hasEventListener | () | método |
public function hasEventListener(type:String):Boolean
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event. This allows you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. To determine whether
a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger()
.
The difference between hasEventListener()
and willTrigger()
is that hasEventListener()
examines only the object to which it belongs, whereas willTrigger()
examines the entire event flow for the event specified by the type
parameter.
Parâmetros
type:String — The type of event.
|
Boolean — A value of true if a listener of the specified type is registered; false otherwise.
|
initialized | () | método |
public function initialized(document:Object, id:String):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Called automatically by the MXML compiler when the ListCollectionView
is created using an MXML tag.
If you create the ListCollectionView through ActionScript, you
must call this method passing in the MXML document and
null
for the id
.
Parâmetros
document:Object — The MXML document containing this ListCollectionView.
| |
id:String — Ignored.
|
itemUpdated | () | método |
public function itemUpdated(item:Object, property:Object = null, oldValue:Object = null, newValue:Object = null):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Notifies the view that an item has been updated.
This method is useful if the contents of the view do not implement
IPropertyChangeNotifier
.
If the call to this method includes a property
parameter,
the view may be able to optimize its notification mechanism.
Otherwise it may choose to simply refresh the whole view.
Parâmetros
item:Object — The item within the view that was updated.
| |
property:Object (default = null ) — The name of the property that was updated.
| |
oldValue:Object (default = null ) — The old value of that property. (If property
was null, this can be the old value of the item.).
| |
newValue:Object (default = null ) — The new value of that property. (If property
was null, there's no need to specify this as the item is assumed
to be the new value.)
|
Elementos da API relacionados
refresh | () | método |
public function refresh():Boolean
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Applies the sort and filter to the view.
The ICollectionView does not detect changes to a sort or
filter automatically, so you must call the refresh()
method to update the view after setting the sort
or filterFunction
property.
If your ICollectionView implementation also implements
the IMXMLObject interface, you should to call the
refresh()
method from your initialized()
method.
Returns true
if the refresh was successful
and false
if the sort is not yet complete
(e.g., items are still pending).
A client of the view should wait for a CollectionEvent event
with the CollectionEventKind.REFRESH
kind
property to ensure that the refresh()
operation is
complete.
Boolean — true if the refresh() was complete,
false if the refresh() is incomplete.
|
removeAll | () | método |
public function removeAll():void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Remove all items from the list.
removeEventListener | () | método |
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.
Parâmetros
type:String — The type of event.
| |
listener:Function — The listener object to remove.
| |
useCapture:Boolean (default = false ) — Specifies whether the listener was registered for the capture phase or the target and bubbling phases. If the listener was registered for both the capture phase and the target and bubbling phases, two calls to removeEventListener() are required to remove both: one call with useCapture set to true , and another call with useCapture set to false .
|
removeItemAt | () | método |
public function removeItemAt(index:int):Object
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Removes the item at the specified index and returns it. Any items that were after this index are now one index earlier.
Parâmetros
index:int — The index from which to remove the item.
|
Object — The item that was removed.
|
setItemAt | () | método |
public function setItemAt(item:Object, index:int):Object
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Places the item at the specified index. If an item was already at that index the new item will replace it and it will be returned.
Parâmetros
item:Object — The new item to be placed at the specified index.
| |
index:int — The index at which to place the item.
|
Object — The item that was replaced, or null if none.
|
toArray | () | método |
toString | () | método |
willTrigger | () | método |
public function willTrigger(type:String):Boolean
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. This method returns true
if an event listener is triggered during any phase of the event flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants.
The difference between hasEventListener()
and willTrigger()
is that hasEventListener()
examines only the object to which it belongs, whereas willTrigger()
examines the entire event flow for the event specified by the type
parameter.
Parâmetros
type:String — The type of event.
|
Boolean — A value of true if a listener of the specified type will be triggered; false otherwise.
|
collectionChange | Evento |
mx.events.CollectionEvent
propriedade CollectionEvent.type =
mx.events.CollectionEvent.COLLECTION_CHANGE
Versão da linguagem: | ActionScript 3.0 |
Versão de produto: | Flex 3 |
Versões de runtime: | Flash Player 9, AIR 1.1 |
Dispatched when the ICollectionView has been updated in some way.
The CollectionEvent.COLLECTION_CHANGE constant defines the value of thetype
property of the event object for an event that is
dispatched when a collection has changed.
The properties of the event object have the following values. Not all properties are meaningful for all kinds of events. See the detailed property descriptions for more information.
Property | Value |
---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
items | An Array of objects with
information about the items affected by the event.
The contents of this field depend on the event kind;
for details see the items property |
kind | The kind of event. The valid values are defined in the CollectionEventKind class as constants. |
location | Location within the target collection
of the item(s) specified in the items property. |
oldLocation | the previous location in the collection
of the item specified in the items property. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
type | CollectionEvent.COLLECTION_CHANGE |
Wed Jun 13 2018, 11:10 AM Z