| Package | qnx.ui.data |
| Class | public class SectionDataProvider |
| Inheritance | SectionDataProvider DataProvider flash.events.EventDispatcher |
| Implements | ISectionDataProvider |
SectionDataProvider class provides a two-dimensional representation of a set of data and methods to enable modification of the data.
The SectionDataProvider class provides data in a sectioned list, where a single list contains multiple items,
with each item containing a list of 0 or more children. The SectionDataProvider class is useful for showing more
complex data lists, such as a calendar of dates, or a catalog of related products.
The SectionList and SectionTileList classes use the SectionDataProvider
class in order to handle their data. The following image shows a SectionDataProvider instance that is used to populate a SectionTileList object
with calendar data.
In the calendar example, the month data is contained within the item sections of the SectionDataProvider object. Each month contains day data, where each day is
stored as the child of an item. For example, the January item contains 31 day children.
See also
| Method | Defined By | ||
|---|---|---|---|
SectionDataProvider(dp:Array = null, dispatchCreate:Boolean = false, initChildren:Dictionary = null)
Creates a SectionDataProvider instance given an array of data items. | SectionDataProvider | ||
addChildToIndex(child:Object, index:int):void
Adds a child to the item at a given index. | SectionDataProvider | ||
addChildToIndexAt(child:Object, index:int, childindex:int):void
Adds a child (at a given child index) to the item at the given index. | SectionDataProvider | ||
addChildToItem(child:Object, item:Object):void
Adds a child to an item, given the child and the item object. | SectionDataProvider | ||
addChildToItemAtIndex(child:Object, item:Object, childindex:int):void
Adds a child to an item at a given index, given the child and the item object. | SectionDataProvider | ||
![]() | addItem(item:Object):void
Adds an item to the DataProvider. | DataProvider | |
![]() | addItemAt(item:Object, index:int):void
Adds an item at the specified index. | DataProvider | |
![]() | addItemsAt(items:Array, index:int):void
Adds an array item at the specified index. | DataProvider | |
![]() |
Creates a clone of this DataProvider. | DataProvider | |
getChildInIndexAt(index:int, childindex:int):Object
Returns a child from an item at a given index, given the index of the child. | SectionDataProvider | ||
getChildInItemAt(item:Object, childindex:int):Object
Returns a child from an item object, given the index of the child. | SectionDataProvider | ||
getChildrenAtIndex(index:int):IDataProvider
Returns the children for a given index. | SectionDataProvider | ||
getChildrenForItem(item:Object):IDataProvider
Returns the children for a given item. | SectionDataProvider | ||
getChildrenLengthAtIndex(index:int):int
Returns the number of children for the item at the given index. | SectionDataProvider | ||
getChildrenLengthForItem(item:Object):int
Returns the number of children for a given item. | SectionDataProvider | ||
![]() | getItemAt(index:int):Object
Returns the item at a given offset. | DataProvider | |
![]() | indexOf(item:Object):int
Returns the index of a given object. | DataProvider | |
indexOfChildAt(index:int, child:Object):int
Returns the index of a child object, given the index of the item that contains the child and the child object. | SectionDataProvider | ||
![]() | removeAll():void
Removes all items from the DataProvider instance. | DataProvider | |
removeAllChildrenFromIndex(index:int):void
Removes all children from the item at a given index. | SectionDataProvider | ||
removeAllChildrenFromItem(item:Object):void
Removes all children from a given item. | SectionDataProvider | ||
removeChildFromIndex(index:int, child:Object):void
Removes a child from an item, given the child and the index of the item. | SectionDataProvider | ||
removeChildFromIndexAt(index:int, childindex:int):void
Removes a child, given the index of the item, and a child index. | SectionDataProvider | ||
removeChildFromItem(item:Object, child:Object):void
Removes the child from an item, given the item and the child. | SectionDataProvider | ||
removeChildFromItemAt(item:Object, childindex:int):void
Removes a child from an item, given the item and the index of the child. | SectionDataProvider | ||
![]() | removeItem(item:Object):void
Removes the item from the DataProvider instance. | DataProvider | |
![]() | removeItemAt(index:int):void
Removes an item from the DataProvider at a given offset. | DataProvider | |
replaceChildInIndex(index:int, child:Object, oldChild:Object):void
Replaces a child in an index, given the index of the child, the item that contains the child, and the old child data. | SectionDataProvider | ||
replaceChildInIndexAt(index:int, child:Object, childindex:int):void
Replaces a child in an index at a given offset. | SectionDataProvider | ||
replaceChildInItem(item:Object, child:Object, oldChild:Object):void
Replaces a child in an item, given the child, the item, and the old child data. | SectionDataProvider | ||
replaceChildInItemAt(item:Object, child:Object, childindex:int):void
Replaces a child in an item at a given index, given the item, the child, and the index of the child. | SectionDataProvider | ||
![]() | replaceItem(item:Object, oldObject:Object):void
Replaces an item, given the new item object and the item to replace. | DataProvider | |
![]() | replaceItemAt(item:Object, index:int):void
Replaces the item at a given offset. | DataProvider | |
setChildrenForIndex(index:int, children:IDataProvider, throwEvent:Boolean = false):void
Sets the children data for a given index. | SectionDataProvider | ||
setChildrenForItem(item:Object, children:IDataProvider, throwEvent:Boolean = false):void
Sets the children data for a given item, given the DataProvider, and a Boolean that determines whether or
not an event will be dispatched. | SectionDataProvider | ||
![]() | setItems(arr:Array, throwEvent:Boolean = false):void
Sets the entire data provider to the new array. | DataProvider | |
updateChildInIndex(index:int, child:Object, oldChild:Object):void
Updates a child in an item, given the index of the item, the child object, and the old child object. | SectionDataProvider | ||
updateChildInIndexAt(index:int, child:Object, childindex:int):void
Updates a child given the index of the parent (item), the child index, and the new child object. | SectionDataProvider | ||
updateChildInItem(item:Object, child:Object, oldChild:Object):void
Updates a child in an item, given the item, the child to update, and the old child object. | SectionDataProvider | ||
updateChildInItemAt(item:Object, child:Object, childindex:int):void
Updates a child in an item, given the item, the child to update, and the index of the child. | SectionDataProvider | ||
![]() | updateItem(item:Object, oldObject:Object):void
Updates an item, given the new item data object and the item to update. | DataProvider | |
![]() | updateItemAt(item:Object, index:int):void
Updates the item at a given offset. | DataProvider | |
![]() | updateItemsAt(items:Array, index:int):void
Updates the items starting at the specified index with new items. | DataProvider | |
| SectionDataProvider | () | Constructor |
public function SectionDataProvider(dp:Array = null, dispatchCreate:Boolean = false, initChildren:Dictionary = null)
Creates a SectionDataProvider instance given an array of data items.
dp:Array (default = null) — The initial array of data items.
| |
dispatchCreate:Boolean (default = false) — Setting this value to true causes a DataProviderEvent.UPDATE_ALL
event to occur on creation. This parameter is set to false by default.
| |
initChildren:Dictionary (default = null) — Initialize the children in the Dictionary.
|
| addChildToIndex | () | method |
public function addChildToIndex(child:Object, index:int):voidAdds a child to the item at a given index.
Parameters
child:Object — The child object to add to the item.
| |
index:int — The index of the item at which to add the child.
|
| addChildToIndexAt | () | method |
public function addChildToIndexAt(child:Object, index:int, childindex:int):voidAdds a child (at a given child index) to the item at the given index.
In the following listing, a child object with the label value myChild is added to the third item, at the fifth index position.
mySDP.addChildToIndexAt( {label: myChild}, 3, 5 );
Parameters
child:Object — The child item to add.
| |
index:int — The index of the item, at which to add the child.
| |
childindex:int — The index within the item, at which to add the child.
|
| addChildToItem | () | method |
public function addChildToItem(child:Object, item:Object):voidAdds a child to an item, given the child and the item object.
In the following listing, a set of 32 day children are added to each month item.
for( var j:int = 1; j<32; j++ )
{
mySDP.addChildToItem( {label: j}, section );
}
Parameters
child:Object — The child object to add to the item.
| |
item:Object — The item object for which to to add the child.
|
| addChildToItemAtIndex | () | method |
public function addChildToItemAtIndex(child:Object, item:Object, childindex:int):voidAdds a child to an item at a given index, given the child and the item object.
In the following listing, day data is added to each month using the day value as the index.
for( var j:int = 1; j<32; j++ )
{
mySDP.addChildToItemAtIndex( {label: j}, section, j );
}
Parameters
child:Object — The child object to add to the item.
| |
item:Object — The item for which to add the child.
| |
childindex:int — The location at which to add the child.
|
| getChildInIndexAt | () | method |
public function getChildInIndexAt(index:int, childindex:int):ObjectReturns a child from an item at a given index, given the index of the child.
In the following example, the second child object (index 1) of the sixth item (index 5) is returned. Remember that the arrays are zero-based.
var myObj:Object = mySDP.getChildInIndexAt(5, 1);
Parameters
index:int — The index of the item from which to return the child.
| |
childindex:int — The index of the child, within the section.
|
Object — The child.
|
| getChildInItemAt | () | method |
public function getChildInItemAt(item:Object, childindex:int):ObjectReturns a child from an item object, given the index of the child.
In the following example, the child at the 4th index position, of the item object at the 5th index position is returned.
var myObjItem:Object = mySDP.getItemAt(5);
var myObj:Object = mySDP.getChildInItemAt(myObjItem, 4);
Parameters
item:Object — The item from which to return the child.
| |
childindex:int — The index of the child to return.
|
Object — The child.
|
| getChildrenAtIndex | () | method |
public function getChildrenAtIndex(index:int):IDataProviderReturns the children for a given index.
Parameters
index:int — The index for which to return the children.
|
IDataProvider — A DataProvider containing the children data.
|
| getChildrenForItem | () | method |
public function getChildrenForItem(item:Object):IDataProviderReturns the children for a given item.
Parameters
item:Object — The item for which to return the children.
|
IDataProvider — A DataProvider containing the children data.
|
| getChildrenLengthAtIndex | () | method |
public function getChildrenLengthAtIndex(index:int):intReturns the number of children for the item at the given index.
Parameters
index:int — The index of the item for which to return the number of children.
|
int — An integer representing the number of children.
|
| getChildrenLengthForItem | () | method |
public function getChildrenLengthForItem(item:Object):intReturns the number of children for a given item.
Parameters
item:Object — The item for which to return the number of children.
|
int — The number of children.
|
| indexOfChildAt | () | method |
public function indexOfChildAt(index:int, child:Object):intReturns the index of a child object, given the index of the item that contains the child and the child object.
Parameters
index:int — The index of the item that contains the child, or -1 if the child is not found.
| |
child:Object — The child object.
|
int — The index of the child or -1.
|
| removeAllChildrenFromIndex | () | method |
public function removeAllChildrenFromIndex(index:int):voidRemoves all children from the item at a given index.
Parameters
index:int — The index of the item from which to remove the children.
|
| removeAllChildrenFromItem | () | method |
public function removeAllChildrenFromItem(item:Object):voidRemoves all children from a given item.
Parameters
item:Object — The item from which to remove all the children.
|
| removeChildFromIndex | () | method |
public function removeChildFromIndex(index:int, child:Object):voidRemoves a child from an item, given the child and the index of the item.
Parameters
index:int — The index of the item that contains the child.
| |
child:Object — The child object to remove.
|
| removeChildFromIndexAt | () | method |
public function removeChildFromIndexAt(index:int, childindex:int):voidRemoves a child, given the index of the item, and a child index.
In the following listing, the 29th, 30th, and 31st days (children) are removed from the second item in the list (February). Remember that the arrays are zero-based.
mySectionTileList.removeChildFromIndexAt(1, 30);
mySectionTileList.removeChildFromIndexAt(1, 29);
mySectionTileList.removeChildFromIndexAt(1, 28);
Parameters
index:int — The index of the item that contains the child.
| |
childindex:int — The index of the child, within the item.
|
| removeChildFromItem | () | method |
public function removeChildFromItem(item:Object, child:Object):voidRemoves the child from an item, given the item and the child.
Parameters
item:Object — The item, from which to remove the child.
| |
child:Object — The child object to remove.
|
| removeChildFromItemAt | () | method |
public function removeChildFromItemAt(item:Object, childindex:int):voidRemoves a child from an item, given the item and the index of the child.
Parameters
item:Object — The item, from which to remove the child.
| |
childindex:int — The index of the child to remove.
|
| replaceChildInIndex | () | method |
public function replaceChildInIndex(index:int, child:Object, oldChild:Object):voidReplaces a child in an index, given the index of the child, the item that contains the child, and the old child data.
Parameters
index:int — The index.
| |
child:Object — The new child item.
| |
oldChild:Object — The child object to replace.
|
| replaceChildInIndexAt | () | method |
public function replaceChildInIndexAt(index:int, child:Object, childindex:int):voidReplaces a child in an index at a given offset.
Parameters
index:int — The index.
| |
child:Object — The new child object.
| |
childindex:int — The index of the child to replace.
|
| replaceChildInItem | () | method |
public function replaceChildInItem(item:Object, child:Object, oldChild:Object):voidReplaces a child in an item, given the child, the item, and the old child data.
Parameters
item:Object — The item that contains the child.
| |
child:Object — The child object to update.
| |
oldChild:Object — The old child object.
|
| replaceChildInItemAt | () | method |
public function replaceChildInItemAt(item:Object, child:Object, childindex:int):voidReplaces a child in an item at a given index, given the item, the child, and the index of the child.
Parameters
item:Object — That item that contains the child.
| |
child:Object — The child object to replace.
| |
childindex:int — The index of the child object to replace.
|
| setChildrenForIndex | () | method |
public function setChildrenForIndex(index:int, children:IDataProvider, throwEvent:Boolean = false):voidSets the children data for a given index.
Parameters
index:int — The index for which to set the children data.
| |
children:IDataProvider — A DataProvider object that contains the children data.
| |
throwEvent:Boolean (default = false) — A Boolean that determines whether or not an update event occurs. false by default.
|
| setChildrenForItem | () | method |
public function setChildrenForItem(item:Object, children:IDataProvider, throwEvent:Boolean = false):void
Sets the children data for a given item, given the DataProvider, and a Boolean that determines whether or
not an event will be dispatched.
Parameters
item:Object — The item for which to add the children.
| |
children:IDataProvider — The DataProvider that contains the children data.
| |
throwEvent:Boolean (default = false) — A Boolean that determines whether or not an event will be dispatched.
|
| updateChildInIndex | () | method |
public function updateChildInIndex(index:int, child:Object, oldChild:Object):voidUpdates a child in an item, given the index of the item, the child object, and the old child object.
Parameters
index:int — The index to update.
| |
child:Object — The new child object.
| |
oldChild:Object — The old child data.
|
| updateChildInIndexAt | () | method |
public function updateChildInIndexAt(index:int, child:Object, childindex:int):voidUpdates a child given the index of the parent (item), the child index, and the new child object.
In the following example, a new child object is added to the SectionDataProvider instance
in the fifth item index, at the 15th index position.
mySDP.updateChildInIndexAt(5, {label: "MyNewChild"}, 15);
Parameters
index:int — The index of the item.
| |
child:Object — The child object to update.
| |
childindex:int — The index of the child to update.
|
| updateChildInItem | () | method |
public function updateChildInItem(item:Object, child:Object, oldChild:Object):voidUpdates a child in an item, given the item, the child to update, and the old child object.
In the following example, a new child object is added to the SectionDataProvider instance
in place of an existing child object.
var myObjItem:Object = mySDP.getItemAt(5);
var myObjChild:Object = mySDP.getChildInItemAt(myObjItem, 7);
mySDP.updateChildInItem(myObjItem, {label: "MyNewChild"}, myObjChild);
Parameters
item:Object — The item that contains the child.
| |
child:Object — The new child object.
| |
oldChild:Object — The child object to update.
|
| updateChildInItemAt | () | method |
public function updateChildInItemAt(item:Object, child:Object, childindex:int):voidUpdates a child in an item, given the item, the child to update, and the index of the child.
Parameters
item:Object — The item that contains the child.
| |
child:Object — The child to update.
| |
childindex:int — The index of the child to update.
|
In the following example, a SectionDataProvider instance is created and populated with calendar data. The SectionDataProvider
is used to create a SectionTileList that is used to render the calendar months and days.
package
{
import flash.display.Sprite;
import qnx.ui.data.SectionDataProvider;
import qnx.ui.listClasses.SectionTileList;
[SWF(height="600", width="1024",
frameRate="30", backgroundColor="#FFFFFF")]
public class sectionTileSample extends Sprite
{
private var mySectionTileList:SectionTileList;
public function sectionTileSample()
{
initializeUI();
normalizeDays();
}
private function initializeUI():void
{
//create and setup section list
mySectionTileList = new SectionTileList();
mySectionTileList.setPosition(100, 50);
mySectionTileList.width = 520;
mySectionTileList.height = 500;
mySectionTileList.columnCount = 5;
mySectionTileList.cellPadding = 5;
mySectionTileList.dataProvider = createDataProvider();
this.addChild(mySectionTileList);
}
private function createDataProvider():SectionDataProvider
{
//populate month name array
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 mySDP:SectionDataProvider = new SectionDataProvider();
//populate section data provider
for( var i:int = 0; i < arrMonth.length; i++ )
{
//add month names
var section:Object = new Object();
section.label = arrMonth[i].label;
mySDP.addItem( section );
//add day numbers, all 31 for now
for( var j:int = 1; j<32; j++ )
{
mySDP.addChildToItem( {label: j}, section );
}
}
return(mySDP);
}
private function normalizeDays():void{
//Remove February Days
//TODO: account for leap years
mySectionTileList.removeChildFromIndexAt(1, 30);
mySectionTileList.removeChildFromIndexAt(1, 29);
mySectionTileList.removeChildFromIndexAt(1, 28);
//Remove April Day
mySectionTileList.removeChildFromIndexAt(3, 30);
//Remove June Day
mySectionTileList.removeChildFromIndexAt(5, 30);
//Remove September Day
mySectionTileList.removeChildFromIndexAt(8, 30);
//Remove November Day
mySectionTileList.removeChildFromIndexAt(10, 30);
}
}
}