Constructor
new CollectionTreeDataSource(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | an object containing the following options: root: an oj.Collection specifying the root level Collection childCollectionCallback: a function(oj.Collection,oj.Model):oj.Collection callback to return a child collection given a root and model representing the parent parseMetadata: a function(oj.Model):Object callback to return key, leaf, depth metadata from a given Model |
- Source:
Methods
-
fetchChildren(parent, range, callbacks, options)
-
Fetch the children
Parameters:
Name Type Argument Description parent
Object 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. range.start the start index of the range in which the children are fetched.
range.count the size of the range in which the children are fetched.
callbacks
Object the callbacks to be invoke when fetch children operation is completed. The valid callback types are "success" and "error". {function(oj.NodeSet)} callbacks.success the callback to invoke when fetch completed successfully.
{function({status: Object})} callbacks.error the callback to invoke when fetch children failed.
options
Object <optional>
optional parameters for this operation. {boolean=} options.queueOnly true if this fetch request is to be queued and not execute yet. The implementation must maintain the order of the fetch operations. When queueOnly is false/null/undefined, any queued fetch operations are then flushed and executed in the order they are queued. This flag is ignored if the datasource does not support batching.
- Source:
-
fetchDescendents(parent, callbacks, options)
-
Fetch all children and their children recursively from a specified parent.
Parameters:
Name Type Argument Description parent
Object 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". {function(oj.CollectionNodeSet)} success the callback to invoke when fetch completed successfully.
{function({status: Object})} error the callback to invoke when fetch children failed.
options
Object <optional>
optional parameters for this operation. {number=} start the index related to parent in which to begin fetching descendents from. If this is not specified, then
{number=} maxCount 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.
- Source:
- ojtree-model/CollectionTreeDataSource.js, line 473
-
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", "fetchDescendents", "batchFetch" - Source:
- ojtree-model/CollectionTreeDataSource.js, line 604
Returns:
the name of the feature. Returns null if the feature is not recognized. For "sort", the valid return values are: "default", "none". For "fetchDescendents", 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)
-
Gets a collection representing the specified parent key's children.
Parameters:
Name Type Description key
Object 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 - Source:
-
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
Object the parent key. Specify null if inquiring child count of the root. - Source:
Returns:
the number of children for the specified parent.- Type
- number
-
getSortCriteria() → {Object}
-
Returns the current sort criteria of the tree data.
- Source:
- ojtree-model/CollectionTreeDataSource.js, line 555
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
- Object
-
handleEvent(eventType, event)
-
Handle the event
Parameters:
Name Type Description eventType
string event type event
Object event - Inherited From:
- Source:
-
Init()
-
Initializes the data source.
- Source:
-
move(rowToMove, referenceRow, position)
-
Moves a row from one location to another (different position within the same parent or a completely different parent)
Parameters:
Name Type Description rowToMove
Object the key of the row to move referenceRow
Object 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.success
function() the callback to invoke when the move completed successfully. callbacks.error
function({status: Object}) the callback to invoke when move failed. - Source:
- ojtree-model/CollectionTreeDataSource.js, line 572
-
moveOK(rowToMove, referenceRow, position) → {string}
-
Checks whether a move operation is valid.
Parameters:
Name Type Description rowToMove
Object the key of the row to move referenceRow
Object 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. - Source:
- ojtree-model/CollectionTreeDataSource.js, line 588
Returns:
returns "valid" if the move is valid, "invalid" otherwise.- Type
- string
-
off(eventType, eventHandler)
-
Detach an event handler from the datasource
Parameters:
Name Type Description eventType
string eventType supported by the datasource eventHandler
function(Object) event handler function - Inherited From:
- Source:
-
on(eventType, eventHandler)
-
Attach an event handler to the datasource
Parameters:
Name Type Description eventType
string eventType supported by the datasource eventHandler
function(Object) event handler function - Inherited From:
- Source:
-
sort(criteria)
-
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 criteria.key the key identifying the attribute (column) to sort on
criteria.direction the sort direction, valid values are "ascending", "descending", "none" (default)
callbacks.success
function({status: Object}) the callback to invoke when the sort completed successfully. callbacks.error the callback to invoke when sort failed.
- Source:
- ojtree-model/CollectionTreeDataSource.js, line 511