Apache Flex 4.16.0 API Reference | All Packages | All Classes | Index | Frames No Frames |
DefaultDataDescriptor

Package | mx.controls.treeClasses
Class | public class DefaultDataDescriptor
Inheritance | DefaultDataDescriptor Object
Implements | ITreeDataDescriptor2, IMenuDataDescriptor

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

The DefaultDataDescriptor class provides a default implementation for accessing and manipulating data for use in controls such as Tree and Menu. This implementation handles e4x XML and object nodes in similar but different ways. See each method description for details on how the method accesses values in nodes of various types. This class is the default value of the Tree, Menu, MenuBar, and PopUpMenuButton control `dataDescriptor` properties.

See also

mx.controls.treeClasses.ITreeDataDescriptor
mx.controls.menuClasses.IMenuDataDescriptor
mx.controls.Menu
mx.controls.MenuBar
mx.controls.PopUpMenuButton
mx.controls.Tree

Public Methods

| Method | Defined By
--- | --- | ---
|  | DefaultDataDescriptor() Constructor. | DefaultDataDescriptor
|  | addChildAt(parent:Object, newChild:Object, index:int, model:Object = null):Boolean Add a child node to a node at the specified index. | DefaultDataDescriptor
|  | getChildren(node:Object, model:Object = null):ICollectionView Provides access to a node's children. | DefaultDataDescriptor
|  | getData(node:Object, model:Object = null):Object Returns a node's data. | DefaultDataDescriptor
|  | getGroupName(node:Object):String Returns the name of the radio button group to which the node belongs, if any. | DefaultDataDescriptor
|  | getHierarchicalCollectionAdaptor(hierarchicalData:ICollectionView, uidFunction:Function, openItems:Object, model:Object = null):ICollectionView Returns an ICollectionView instance that makes the hierarchical data appear as if it was a linear ICollectionView instance. | DefaultDataDescriptor
|  | getNodeDepth(node:Object, iterator:IViewCursor, model:Object = null):int Returns the depth of the node, meaning the number of ancestors it has. | DefaultDataDescriptor
|  | getParent(node:Object, collection:ICollectionView, model:Object = null):Object Returns the parent of the node The parent of a top-level node is null. | DefaultDataDescriptor
|  | getType(node:Object):String Returns the type identifier of a node. | DefaultDataDescriptor
|  | hasChildren(node:Object, model:Object = null):Boolean Determines if the node actually has children. | DefaultDataDescriptor
|  | isBranch(node:Object, model:Object = null):Boolean Tests a node for termination. | DefaultDataDescriptor
|  | isEnabled(node:Object):Boolean Returns whether the node is enabled. | DefaultDataDescriptor
|  | isToggled(node:Object):Boolean Returns whether the node is toggled. | DefaultDataDescriptor
|  | removeChildAt(parent:Object, child:Object, index:int, model:Object = null):Boolean Removes the child node from a node at the specified index. | DefaultDataDescriptor
|  | setEnabled(node:Object, value:Boolean):void Sets the value of the field or attribute in the data provider that identifies whether the node is enabled. | DefaultDataDescriptor
|  | setToggled(node:Object, value:Boolean):void Sets the value of the field or attribute in the data provider that identifies whether the node is toggled. | DefaultDataDescriptor

Constructor Detail

DefaultDataDescriptor | () | Constructor

`public function DefaultDataDescriptor()`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Constructor.

Method Detail

addChildAt | () | method

`public function addChildAt(parent:Object, newChild:Object, index:int, model:Object = null):Boolean`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Add a child node to a node at the specified index. This implementation does the following:

- If the `parent` parameter is null or undefined, inserts the `child` parameter at the specified index in the collection specified by `model` parameter.
- If the `parent` parameter has a `children` field or property, the method adds the `child` parameter to it at the `index` parameter location. In this case, the `model` parameter is not required.
- If the `parent` parameter does not have a `children` field or property, the method adds the `children` property to the `parent`. The method then adds the `child` parameter to the parent at the `index` parameter location. In this case, the `model` parameter is not required.
- If the `index` value is greater than the collection length or number of children in the parent, adds the object as the last child.

Parameters

| `parent:Object` — The node object that will parent the child.
| `newChild:Object` — The node object that will be parented by the node.
| `index:int` — The 0-based index of where to put the child node relative to the parent.
| `model:Object` (default = `null`)`` — The entire collection that this node is a part of.

Returns

| `Boolean` — `true` if successful.

getChildren | () | method |

`public function getChildren(node:Object, model:Object = null):ICollectionView`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Provides access to a node's children. Returns a collection of children if they exist. If the node is an Object, the method returns the contents of the object's `children` field as an ArrayCollection. If the node is XML, the method returns an XMLListCollection containing the child elements.

Parameters

| `node:Object` — The node object currently being evaluated.
| `model:Object` (default = `null`)`` — The collection that contains the node; ignored by this class.

Returns

| `ICollectionView` — An object containing the children nodes.

getData | () | method |

`public function getData(node:Object, model:Object = null):Object`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns a node's data. Currently returns the entire node.

Parameters

| `node:Object` — The node object currently being evaluated.
| `model:Object` (default = `null`)`` — The collection that contains the node; ignored by this class.

Returns

| `Object` — The node.

getGroupName | () | method |

`public function getGroupName(node:Object):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns the name of the radio button group to which the node belongs, if any. This method is used by menu-based controls.

Parameters

| `node:Object` — The node for which to get the group name.

Returns

| `String` — The value of the node's `groupName` attribute or field, or an empty string if there is no such entry.

getHierarchicalCollectionAdaptor | () | method |

`public function getHierarchicalCollectionAdaptor(hierarchicalData:ICollectionView, uidFunction:Function, openItems:Object, model:Object = null):ICollectionView`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns an ICollectionView instance that makes the hierarchical data appear as if it was a linear ICollectionView instance.

Parameters

| `hierarchicalData:ICollectionView` — The hierarchical data.
| `uidFunction:Function` — A function that takes an Object and returns the UID, as a String. This parameter is usually the `Tree.itemToUID()` method.
| `openItems:Object` — The items that have been opened or set opened.
| `model:Object` (default = `null`)`` — The collection to which this node belongs.

Returns

| `ICollectionView` — An ICollectionView instance.

getNodeDepth | () | method |

`public function getNodeDepth(node:Object, iterator:IViewCursor, model:Object = null):int`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns the depth of the node, meaning the number of ancestors it has.

Parameters

| `node:Object` — The Object that defines the node.
| `iterator:IViewCursor` — An IViewCursor instance that could be used to do the calculation.
| `model:Object` (default = `null`)`` — The collection to which this node belongs.

Returns

| `int` — The depth of the node, where 0 corresponds to the top level, and -1 if the depth cannot be calculated.

getParent | () | method |

`public function getParent(node:Object, collection:ICollectionView, model:Object = null):Object`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns the parent of the node The parent of a top-level node is `null`.

Parameters

| `node:Object` — The Object that defines the node.
| `collection:ICollectionView` — An ICollectionView instance that could be used to do the calculation.
| `model:Object` (default = `null`)`` — The collection to which this node belongs.

Returns

| `Object` — The parent node containing the node as child, `null` for a top-level node, and `undefined` if the parent cannot be determined.

getType | () | method |

`public function getType(node:Object):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns the type identifier of a node. This method is used by menu-based controls to determine if the node represents a separator, radio button, a check box, or normal item.

Parameters

| `node:Object` — The node object for which to get the type.

Returns

| `String` — The value of the `type` attribute or field, or the empty string if there is no such field.

hasChildren | () | method |

`public function hasChildren(node:Object, model:Object = null):Boolean`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Determines if the node actually has children.

Parameters

| `node:Object` — The node object currently being evaluated.
| `model:Object` (default = `null`)`` — The collection that contains the node; ignored by this class.

Returns

| `Boolean` — `true` if this node currently has children.

isBranch | () | method |

`public function isBranch(node:Object, model:Object = null):Boolean`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Tests a node for termination. Branches are non-terminating but are not required to have any leaf nodes. If the node is XML, returns `true` if the node has children or a `true isBranch` attribute. If the node is an object, returns `true` if the node has a (possibly empty) `children` field.

Parameters

| `node:Object` — The node object currently being evaluated.
| `model:Object` (default = `null`)`` — The collection that contains the node; ignored by this class.

Returns

| `Boolean` — `true` if this node is non-terminating.

isEnabled | () | method |

`public function isEnabled(node:Object):Boolean`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns whether the node is enabled. This method is used by menu-based controls.

Parameters

| `node:Object` — The node for which to get the status.

Returns

| `Boolean` — The value of the node's `enabled` attribute or field, or `true` if there is no such entry or the value is not `false`.

isToggled | () | method |

`public function isToggled(node:Object):Boolean`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns whether the node is toggled. This method is used by menu-based controls.

Parameters

| `node:Object` — The node for which to get the status.

Returns

| `Boolean` — The value of the node's `toggled` attribute or field, or `false` if there is no such entry.

removeChildAt | () | method |

`public function removeChildAt(parent:Object, child:Object, index:int, model:Object = null):Boolean`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Removes the child node from a node at the specified index. If the `parent` parameter is null or undefined, the method uses the `model` parameter to access the child; otherwise, it uses the `parent` parameter and ignores the `model` parameter.

Parameters

| `parent:Object` — The node object that currently parents the child node.
| `child:Object` — The node that is being removed.
| `index:int` — The 0-based index of the child node to remove relative to the parent.
| `model:Object` (default = `null`)`` — The entire collection that this node is a part of.

Returns

| `Boolean` — `true` if successful.

setEnabled | () | method |

`public function setEnabled(node:Object, value:Boolean):void`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Sets the value of the field or attribute in the data provider that identifies whether the node is enabled. This method sets the value of the node's `enabled` attribute or field. This method is used by menu-based controls.

Parameters

| `node:Object` — The node for which to set the status.
| `value:Boolean` — Whether the node is enabled.

setToggled | () | method |

`public function setToggled(node:Object, value:Boolean):void`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Sets the value of the field or attribute in the data provider that identifies whether the node is toggled. This method sets the value of the node's `toggled` attribute or field. This method is used by menu-based controls.

Parameters

| `node:Object` — The node for which to set the status.
| `value:Boolean` — Whether the node is toggled.

Sun Mar 5 2017, 03:42 PM +11:00