Final Class: CollectionTreeDataSource

Oracle® JavaScript Extension Toolkit (JET)
15.1.0

F83698-01

Since:
  • 1.0
Module:
  • ojcollectiontreedatasource

Note: This class is deprecated since 14.0.0. CollectionTreeDataSource has been deprecated, use RESTTreeDataProvider instead.

QuickNav

Description

TreeDataSource implementation that represents hierachical data available from an Collection object, such as an external data source. This data source can be used by ListView, NavigationList, and TreeView.

See the Tree View - Data Source: Collection demo for an example.

Refer to TreeDataSource for other data sources that represent hierarachical data.


Usage

For additional information visit:


Final classes in JET

Classes in JET are generally final and do not support subclassing. At the moment, final is not enforced. However, this will likely change in an upcoming JET release.


Properties:
Name Type Argument Description
options.childCollectionCallback function(Collection,Model):Collection callback to return a child collection given a root and model representing the parent
options.parseMetadata function(Model):{key: *, leaf: boolean, depth: number} callback to return key, leaf, depth metadata from a given Model
options.root Collection <optional>
an Collection specifying the root level Collection

Constructor

new CollectionTreeDataSource(options)

Parameters:
Name Type Argument Description
options Object <optional>
an object containing optional properties.
Properties:
Name Type Argument Description
options.childCollectionCallback function(Collection,Model):Collection callback to return a child collection given a root and model representing the parent
options.parseMetadata function(Model):{key: *, leaf: boolean, depth: number} callback to return key, leaf, depth metadata from a given Model
options.root Collection <optional>
an Collection specifying the root level Collection

Methods

fetchChildren(parent, range, callbacks, options) : {void}

Fetch the children
Parameters:
Name Type Argument Description
parent any the parent key. Specify null if fetching children from the root.
range Object information about the range, it must contain the following properties: start, count
callbacks Object the callbacks to be invoke when fetch children operation is completed. The valid callback types are "success" and "error".
options Object <optional>
optional parameters for this operation. Currently this is used for future expansion only.
Properties:
Name Type Argument Description
callbacks.error function({status: *}) <optional>
the callback to invoke when fetch children failed.
callbacks.success function(oj.CollectionNodeSet):void the callback to invoke when fetch completed successfully.
range.count number the size of the range in which the children are fetched
range.start number the start index of the range in which the children are fetched
Returns:
Type
void

fetchDescendants(parent, callbacks, options) : {void}

Fetch all children and their children recursively from a specified parent.
Parameters:
Name Type Argument Description
parent any the parent key. Specify null to fetch everything from the root (i.e. expand all)
callbacks Object the callbacks to be invoke when fetch children operation is completed. The valid callback types are "success" and "error".
options Object <optional>
optional parameters for this operation
Properties:
Name Type Argument Description
callbacks.error function({status: *}) <optional>
the callback to invoke when fetch children failed.
callbacks.success function(oj.CollectionNodeSet):void the callback to invoke when fetch completed successfully.
options.maxCount number <optional>
the maximum number of children to fetch. If a non-positive number is specified, then the value is ignored and there is no maximum fetch count
options.start number <optional>
the index related to parent in which to begin fetching descendants from. If this is not specified, then value zero will be used
Returns:
Type
void

getCapability(feature) : {string|null}

Determines whether this CollectionTreeDataSource supports the specified feature.
Parameters:
Name Type Description
feature string the feature in which its capabilities is inquired. Currently the valid features "sort", "move", "fetchDescendants", "batchFetch"
Returns:

the name of the feature. Returns null if the feature is not recognized. For "sort", the valid return values are: "default", "none". For "fetchDescendants", the valid return values are: "enable", "disable", "suboptimal". For "move", the valid return values are: "default", "none". For "batchFetch", the valid return values are: "enable", "disable".

Type
string | null

getChildCollection(key, callbacks) : {void}

Gets a collection representing the specified parent key's children.
Parameters:
Name Type Description
key any the parent key in which to create an OJ collection for.
callbacks Object success and error callbacks. The success callback will provide the child collection as the first argument
Properties:
Name Type Argument Description
callbacks.error function({status: *}) <optional>
the callback to invoke when the fetch failed.
callbacks.success function(oj.Collection):void the callback to invoke when child collection is fetched successfully.
Returns:
Type
void

getChildCount(parent) : {number}

Returns the number of children for a specified parent. If the value returned is not >= 0 then it is automatically assumed that the child count is unknown.
Parameters:
Name Type Description
parent any the parent key. Specify null if inquiring child count of the root.
Returns:

the number of children for the specified parent.

Type
number

getSortCriteria : {{key: any, direction: ('ascending'|'descending'|'none')}}

Returns the current sort criteria of the tree data.
Returns:

the current sort criteria. It should contain the following properties: key, direction where criteria.key the key identifying the attribute (column) to sort on. Value is null if it's not sorted. criteria.direction the sort direction, valid values are "ascending", "descending", "none" (default)

Type
{key: any, direction: ('ascending'|'descending'|'none')}

handleEvent(eventType, event) : {boolean}

Handle the event
Parameters:
Name Type Description
eventType string event type
event Object event
Inherited From:
Returns:

Returns false if event is cancelled

Type
boolean

Init : {void}

Initializes the data source.
Returns:
Type
void

move(rowToMove, referenceRow, position, callbacks) : {void}

Moves a row from one location to another (different position within the same parent or a completely different parent)
Parameters:
Name Type Description
rowToMove any the key of the row to move
referenceRow any the key of the reference row which combined with position are used to determine the destination of where the row should moved to.
position number | string The position of the moved row relative to the reference row. This can be a string: "before", "after", "inside", "first", "last", or the zero based index to position the element at a specific point among the reference row's current children.
callbacks Object the callbacks for the move function
Properties
Name Type Argument Description
success function():void the callback to invoke when the move completed successfully.
error function({status: *}) <optional>
the callback to invoke when move failed.
Returns:
Type
void

moveOK(rowToMove, referenceRow, position) : {('valid'|'invalid')}

Checks whether a move operation is valid.
Parameters:
Name Type Description
rowToMove any the key of the row to move
referenceRow any the key of the reference row which combined with position are used to determine the destination of where the row should moved to.
position number | string The position of the moved row relative to the reference row. This can be a string: "before", "after", "inside", "first", "last", or the zero based index to position the element at a specific point among the reference row's current children.
Returns:

returns "valid" if the move is valid, "invalid" otherwise.

Type
('valid'|'invalid')

off(eventType, eventHandler) : {void}

Detach an event handler.

Application can call this if it no longer wants to be notified of an event that it has attached an handler to using the on method.

Parameters:
Name Type Description
eventType string eventType
eventHandler function(Object) event handler function
Inherited From:
Returns:
Type
void

on(eventType, eventHandler) : {void}

Attach an event handler.

Application can call this if it wants to be notified of an event. It can call the off method to detach the handler when it no longer wants to be notified.

Parameters:
Name Type Description
eventType string eventType
eventHandler function(Object) event handler function
Inherited From:
Returns:
Type
void

sort(criteria, callbacks) : {void}

Performs a sort operation on the tree data.
Parameters:
Name Type Description
criteria Object the sort criteria. It must contain the following properties: key, direction
Properties
Name Type Description
key any the key identifying the attribute (column) to sort on
direction 'ascending' | 'descending' | 'none' the sort direction, valid values are "ascending", "descending", "none" (default)
callbacks Object callbacks for the sort operation
Properties:
Name Type Argument Description
callbacks.error function({status: *}) <optional>
the callback to invoke when sort failed.
callbacks.success function():void the callback to invoke when the sort completed successfully
Returns:
Type
void