qnx.ui.data.IDataProvider

IDataProvider

Properties | Methods


Packageqnx.ui.data
Interfacepublic interface IDataProvider extends flash.events.IEventDispatcher
Implementors DataProvider

The interface for the DataProvider class.

Class information:
PlayBook Tablet OS Version:   1.0.6

See also

DataProvider



Public Properties

 PropertyDefined By
  data : Array
[read-only] Returns the Array of item data.
IDataProvider
  length : int
[read-only] Returns the length of the data.
IDataProvider

Public Methods

 MethodDefined By
  
addItem(item:Object):void
Adds an item to the DataProvider.
IDataProvider
  
addItemAt(item:Object, index:int):void
Adds an item at the specified index.
IDataProvider
  
addItemsAt(items:Array, index:int):void
Adds an array item at the specified index.
IDataProvider
  
Clones the DataProvider instance.
IDataProvider
  
getItemAt(index:int):Object
Returns the item at a given offset.
IDataProvider
  
indexOf(obj:Object):int
Returns the index of a given object.
IDataProvider
  
removeAll():void
Removes all items from the DataProvider instance.
IDataProvider
  
removeItem(item:Object):void
Removes the item from the DataProvider instance.
IDataProvider
  
removeItemAt(index:int):void
Removes an item from the DataProvider at a given offset.
IDataProvider
  
replaceItem(item:Object, oldObject:Object):void
Replaces an item, given the new item object and the item to replace.
IDataProvider
  
replaceItemAt(item:Object, index:int):void
Replaces the item at a given offset.
IDataProvider
  
setItems(arr:Array, throwEvent:Boolean = false):void
Sets the entire data provider to the new array.
IDataProvider
  
updateItem(item:Object, oldObject:Object):void
Updates an item, given the new item data object and the item to update.
IDataProvider
  
updateItemAt(item:Object, index:int):void
Updates the item at a given offset.
IDataProvider
  
updateItemsAt(items:Array, index:int):void
Updates the items starting at the specified index with new items.
IDataProvider

Property Detail

data


data:Array  [read-only]

Returns the Array of item data.


Implementation

public function get data():Array

length


length:int  [read-only]

Returns the length of the data.


Implementation

public function get length():int

Method Detail

addItem()


public function addItem(item:Object):void

Adds an item to the DataProvider. The item is added to the end of the DataProvider.

In the following example, a new object is created and added to a List. The object is instantiated, and the label property is set. By default, the List object uses the label property of each item to render the item labels in the List.

         var myObj:Object = new Object();
         myObj.label = "Bread";
         
         myList.addItem(myObj);
         

Parameters

item:Object — The item object to add.

See also

addItemAt()

addItemAt()


public function addItemAt(item:Object, index:int):void

Adds an item at the specified index.

The following listing adds an object with the label "December" to the fifth index position of the DataProvider.

        myDP.addItemAt({label: "December"}, 5);
        

Parameters

item:Object — The item object to add.
index:int — The index, or offset, at which to add the item.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

addItem()

addItemsAt()


public function addItemsAt(items:Array, index:int):void

Adds an array item at the specified index.

In the following listing, an Array is created and added to a List at the third index position.

        var myArr:Array = new Array();
        myArr.push({label: "Juice"}, {label: "Tooth paste"}, {label: "Soap"});
        
        myList.addItemsAt(myArr, 3);
        

Parameters

items:Array — The array of items to add.
index:int — The index, or offset, at which to add the items.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

addItem()
addItemAt()

clone()


public function clone():IDataProvider

Clones the DataProvider instance.

Returns

IDataProvider — A new DataProvider instance.

getItemAt()


public function getItemAt(index:int):Object

Returns the item at a given offset.

Parameters

index:int — The offset of the item to return.

Returns

Object — The item object.

Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

indexOf()


public function indexOf(obj:Object):int

Returns the index of a given object.

Parameters

obj:Object — The object for which to return the index.

Returns

int — The index of the object. Returns -1 if the item is not found in the DataProvider.

removeAll()


public function removeAll():void

Removes all items from the DataProvider instance.

See also

removeItem()
removeItemAt()

removeItem()


public function removeItem(item:Object):void

Removes the item from the DataProvider instance.

Parameters

item:Object — The item to remove.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

removeItemAt()
removeAll()

removeItemAt()


public function removeItemAt(index:int):void

Removes an item from the DataProvider at a given offset.

The following example removes the first item in the DataProvider.

         myList.removeItemAt(0);
         

Parameters

index:int — The offset of the item to remove.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

removeItem()
removeAll()

replaceItem()


public function replaceItem(item:Object, oldObject:Object):void

Replaces an item, given the new item object and the item to replace.

Parameters

item:Object — The new item object data.
oldObject:Object — The item to replace.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

replaceItemAt()

replaceItemAt()


public function replaceItemAt(item:Object, index:int):void

Replaces the item at a given offset.

In the following example, the first item in the DataProvider is replaced with a new item.

         myList.replaceItemAt(myObj, 0);
         

Parameters

item:Object — The new item object.
index:int — The offset of the item to replace.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

replaceItem()

setItems()


public function setItems(arr:Array, throwEvent:Boolean = false):void

Sets the entire data provider to the new array.

The following listing creates an array of objects and applies the array to the DataProvider using the setItems() method.

        var arrMonth:Array=[];
        arrMonth.push({label: "January"});
        arrMonth.push({label: "February"});
        arrMonth.push({label: "March"});
        arrMonth.push({label: "April"});
        arrMonth.push({label: "May"});
        arrMonth.push({label: "June"});
        arrMonth.push({label: "July"});
        arrMonth.push({label: "August"});
        arrMonth.push({label: "September"});
        arrMonth.push({label: "October"});
        arrMonth.push({label: "November"});
        arrMonth.push({label: "December"});
        
        var myDP:DataProvider = new DataProvider();
        myDP.setItems(arrMonth);
        

Parameters

arr:Array — An Array of new values.
throwEvent:Boolean (default = false) — When set to true, a DataProviderEvent.UPDATE_ALL event is fired. The default is false.

updateItem()


public function updateItem(item:Object, oldObject:Object):void

Updates an item, given the new item data object and the item to update.

Parameters

item:Object — The new item.
oldObject:Object — The item to update.

updateItemAt()


public function updateItemAt(item:Object, index:int):void

Updates the item at a given offset.

Parameters

item:Object — The new item object data.
index:int — The offset at which to update the item.


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

updateItem()
updateItemsAt()

updateItemsAt()


public function updateItemsAt(items:Array, index:int):void

Updates the items starting at the specified index with new items.

Parameters

items:Array — The new items to be updated.
index:int — The start index to update the items


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

updateItem()
updateItemAt()