Class: IndexerModelTreeDataSource

Oracle® JavaScript Extension Toolkit (JET)
3.2.0

E87541-01

QuickNav

oj. IndexerModelTreeDataSource extends oj.TreeDataSource

Version:
  • 3.2.0
Implementation of the IndexerModel and TreeDataSource

Constructor

new IndexerModelTreeDataSource(data, idAttribute, listener, options)

Implementation of the IndexerModel and TreeDataSource based on an array of data set. This should be used with the Indexer and its associated ListView. By default, this adapter groups the data based on the first letter of the data and the alphabet of the current locale.
Parameters:
Name Type Argument Description
data Array.<Object> an array of data used for Indexer and ListView
idAttribute string the id attribute of the data
listener function(Object) a callback function that handles when a section becomes current (user clicks on the section in the Indexer). the function takes the current section and must return a Promise which when resolve returns the section in which the ListView actually scrolls to.
options Object <optional>
the options set on this IndexerModelTreeDataSource
Properties
Name Type Argument Description
sections Array.<Object> <optional>
the set of sections to use with the Indexer. If not specified, then the sections are derived from the alphabet of the current locale.
groupingAttribute string <optional>
the attribute of the data where grouping is based on, mandatory if no groupingStrategy is specified.
groupingStrategy function(Object) <optional>
a callback function that takes a data and returns the section that the data belongs to. If no groupingStrategy is specified, then the default grouping strategy based on the first letter of the data is used.
sortComparatorFunction function(Object, Object) <optional>
a comparator function that is used to sort data within a section. If not specified, then the items within a section will not be sorted.
Source:

Methods

#fetchChildren(parentKey, range, callbacks, options)

Fetch the children
Parameters:
Name Type Argument Description
parentKey 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.
Properties
Name Type Description
start number the start index of the range in which the children are fetched.
count number 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".
Properties
Name Type Description
success function(oj.NodeSet) the callback to invoke when fetch completed successfully.
error function({status: Object}) the callback to invoke when fetch children failed.
options Object <optional>
optional parameters for this operation.
Properties
Name Type Argument Description
queueOnly boolean <optional>
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:

#fetchDescendants(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".
Properties
Name Type Description
success function(oj.NodeSet) the callback to invoke when fetch completed successfully.
error function({status: Object}) the callback to invoke when fetch children failed.
options Object <optional>
optional parameters for this operation.
Properties
Name Type Argument Description
start number <optional>
the index related to parent in which to begin fetching descendants from. If this is not specified, then
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.
Inherited From:
Source:

#getCapability(feature) → {string|null}

Determines whether this TreeDataSource 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"
Inherited From:
Source:
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

#getChildCount(parentKey) → {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
parentKey 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

#getIndexableSections() → {Array.<Object>}

Returns an array of objects each representing a section in the associated ListView.
Source:
Returns:
an array of all indexable sections
Type
Array.<Object>

#getMissingSections() → {Array.<Object>}

Returns an array of objects each representing a section that does not have a corresponding section in the associated ListView. It must be a subset of the return value of getIndexableSections. Return null or undefined if there's nothing missing.
Source:
Returns:
an array of missing sections
Type
Array.<Object>

#getSortCriteria() → {Object}

Returns the current sort criteria of the tree data.
Inherited From:
Source:
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) → {boolean}

Handle the event
Parameters:
Name Type Description
eventType string event type
event Object event
Inherited From:
Source:
Returns:
Returns false if event is cancelled
Type
boolean

#Init()

Initializes the instance.
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.
Inherited From:
Source:

#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.
Inherited From:
Source:
Returns:
returns "valid" if the move is valid, "invalid" otherwise.
Type
string

off(eventType, eventHandler)

Detach an event handler
Parameters:
Name Type Description
eventType string eventType
eventHandler function(Object) event handler function
Inherited From:
Source:

on(eventType, eventHandler)

Attach an event handler
Parameters:
Name Type Description
eventType string eventType
eventHandler function(Object) event handler function
Inherited From:
Source:

#setSection(section) → {Promise}

Make a section current in the Indexer. The implementation should scroll the associated ListView so that the section becomes visible.
Parameters:
Name Type Description
section Object the current section
Source:
Returns:
a Promise which when resolved will return the section that the associated ListView actually scrolls to. For example, the implementation could choose to scroll to the next available section in ListView if no data exists for that section.
Type
Promise

#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
Properties
Name Type Description
key Object the key identifying the attribute (column) to sort on {string} criteria.direction the sort direction, valid values are "ascending", "descending", "none" (default)
callbacks.success function() the callback to invoke when the sort completed successfully.
callbacks.error function({status: Object}) the callback to invoke when sort failed.
Inherited From:
Source: