Constructor
new FlattenedTreeDataGridDataSource(treeDataSource, options)
The DataGrid specific implementation of the FlattenedTreeDataSource class.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
treeDataSource |
Object | the instance of TreeDataSource to flattened | |
options |
Object |
<optional> |
the options set on this data source. See documentation for a list of supported options. |
Methods
-
collapse(rowKey)
-
Collapse the specified row.
Parameters:
Name Type Description rowKeyObject the key of the row to collapse - Inherited From:
- Source:
-
Destroy()
-
Destroy the data source.
- Inherited From:
- Source:
-
expand(rowKey)
-
Expand the specified row.
Parameters:
Name Type Description rowKeyObject the key of the row to expand - Inherited From:
- Source:
-
fetchCells(cellRanges, callbacks, callbackObjects)
-
Fetch a range of cells from the data source.
Parameters:
Name Type Argument Description cellRangesArray.<Object> Information about the cell range. A cell range is defined by an array of range info for each axis, where each range contains three properties: axis, start, count. Properties
Name Type Description axisstring the axis associated with this range where cells are fetched. Valid values are "row" and "column". startnumber the start index of the range for this axis in which the cells are fetched. countnumber the size of the range for this axis in which the cells are fetched. callbacksObject the callbacks to be invoke when fetch cells operation is completed. The valid callback types are "success" and "error". Properties
Name Type Description successfunction(oj.CellSet) the callback to invoke when fetch cells completed successfully. errorfunction({status: Object}) the callback to invoke when fetch cells failed. callbackObjectsObject <optional>
the object in which the callback function is invoked on. This is optional. You can specify the callback object for each callbacks using the "success" and "error" keys. -
fetchHeaders(headerRange, callbacks, callbackObjects)
-
Fetch a range of headers from the data source.
Parameters:
Name Type Argument Description headerRangeObject information about the header range, it must contain the following properties: axis, start, count. Properties
Name Type Description axisstring the axis of the header that are fetched. Valid values are "row" and "column". startnumber the start index of the range in which the header data are fetched. countnumber the size of the range in which the header data are fetched. callbacksObject the callbacks to be invoke when fetch headers operation is completed. The valid callback types are "success" and "error". Properties
Name Type Description successfunction(oj.HeaderSet) the callback to invoke when fetch headers completed successfully. errorfunction({status: Object}) the callback to invoke when fetch cells failed. callbackObjectsObject <optional>
the object in which the callback function is invoked on. This is optional. You can specify the callback object for each callbacks using the "success" and "error" keys. -
getCapability(feature) → {string|null}
-
Determines whether this DataGridDataSource supports certain feature.
Parameters:
Name Type Description featurestring the feature in which its capabilities is inquired. Currently the only valid feature is "sort". Returns:
the name of the feature. For "sort", the valid return values are: "full", "none", "row", "column". Returns null if the feature is not recognized.- Type
- string | null
-
getCount(axis) → {number}
-
Returns the total number of rows or columns. If the value return is not >= 0 then it is automatically assumed that the total count is unknown.
Parameters:
Name Type Description axisstring the axis in which we inquire for the total count. Valid values are "row" and "column". Returns:
the total number of rows/columns.- Type
- number
-
getCountPrecision(axis) → {string}
-
Returns whether the total count returned in getCount function is an actual or an estimate.
Parameters:
Name Type Description axisstring the axis in which we inquire whether the total count is an estimate. Valid values are "row" and "column". Returns:
"exact" if the count returned in getCount function is the actual count, "estimate" if the count returned in getCount function is an estimate. The default value is "exact".- Type
- string
-
getExpandedKeys() → {Array.<Object>|string}
-
Retrieves the expanded row keys
- Inherited From:
- Source:
Returns:
an array of expanded row keys or 'all' if all rows are expanded.- Type
- Array.<Object> | string
-
getOption(option) → {Object}
-
Retreives the value of the specified option.
Parameters:
Name Type Description optionstring the option to retrieve the value. - Inherited From:
- Source:
Returns:
the value of the specified option. Returns null if the value is null or if the option is not recognized.- Type
- Object
-
getWrappedDataSource() → {Object}
-
Retrieves the underlying TreeDataSource.
- Inherited From:
- Source:
Returns:
the underlying oj.TreeDataSource.- Type
- Object
-
handleEvent(eventType, event) → {boolean}
-
Handle the event
Parameters:
Name Type Description eventTypestring event type eventObject event - Inherited From:
- Source:
Returns:
Returns false if event is cancelled- Type
- boolean
-
indexes(keys) → {Promise}
-
Returns the row and column index based on the keys.
Parameters:
Name Type Description keysObject the key for each axis Properties
Name Type Description rowObject the key for the row axis columnObject the key for the column axis Returns:
a promise object containing the index for each axis, or null if not found- Type
- Promise
-
Init()
-
Initializes the data source.
-
keys(indexes) → {Promise}
-
Returns the keys based on the indexes.
Parameters:
Name Type Description indexesObject the index for each axis Properties
Name Type Description rowObject the index for the row axis columnObject the index for the column axis Returns:
a Promise object which upon resolution will pass in an object containing the keys for each axis, or null if not found- Type
- Promise
-
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 rowToMoveObject the key of the row to move referenceRowObject the key of the reference row which combined with position are used to determine the destination of where the row should moved to. positionstring The position of the moved row relative to the reference row. Valid values are: "before", "after". callbacks.successfunction() the callback to invoke when the move completed successfully. callbacks.errorfunction({status: Object}) the callback to invoke when move failed. -
off(eventType, eventHandler)
-
Detach an event handler
Parameters:
Name Type Description eventTypestring eventType eventHandlerfunction(Object) event handler function - Inherited From:
- Source:
-
on(eventType, eventHandler)
-
Attach an event handler
Parameters:
Name Type Description eventTypestring eventType eventHandlerfunction(Object) event handler function - Inherited From:
- Source:
-
sort(criteria, callbacks, callbackObjects)
-
Performs a sort on the data source.
Parameters:
Name Type Argument Description criteriaObject the sort criteria. Properties
Name Type Description axisstring The axis in which the sort is performed, valid values are "row", "column" keyObject The key that identifies which header to sort directionstring the sort direction, valid values are "ascending", "descending", "none" (default) callbacksObject the callbacks to be invoke upon completion of the sort operation. The callback properties are "success" and "error". Properties
Name Type Description successfunction() the callback to invoke when the sort completed successfully. errorfunction({status: Object}) the callback to invoke when sort failed. callbackObjectsObject <optional>
the object in which the callback function is invoked on. This is optional. You can specify the callback object for each callbacks using the "success" and "error" properties.
Non-public Methods
-
<protected> _fetchRowsFromChildren(range)
-
Fetch a range of rows from the underlying TreeDataSource.
Parameters:
Name Type Description rangeObject the range of rows to fetch. This is the range in a flattened view. Properties
Name Type Description startnumber the start of the range in a flattened view countnumber the number of rows to fetch - Inherited From:
- Source:
-
<protected> _fetchRowsFromDescendants(range)
-
Fetch a range of rows from the underlying TreeDataSource using the fetchDescendants method.
Parameters:
Name Type Description rangeObject the range of rows to fetch. This is the range in a flattened view. Properties
Name Type Description startnumber the start of the range in a flattened view countnumber the number of rows to fetch - Inherited From:
- Source:
-
<protected> fetchRows(range)
-
Fetch a range of rows from the underlying data source. This is a convenient method that the subclasses should use to fetch from the underlying TreeDataSource. This method will take care of the index mapping between a flattened range to tree indexes.
Parameters:
Name Type Description rangeObject the range of rows to fetch. This is the range in a flattened view. Properties
Name Type Description startnumber the start of the range in a flattened view countnumber the number of rows to fetch - Inherited From:
- Source:
-
<protected> getAncestors(rowKey) → {Array}
-
Returns the key of the ancestors.
Parameters:
Name Type Description rowKeyObject the row key to find the ancestors. - Inherited From:
- Source:
Returns:
an array of the key of the ancestors from root to the row with specified row key.- Type
- Array
-
<protected> getFetchedRange() → {Object}
-
Returns the currently fetched range.
- Inherited From:
- Source:
Returns:
the fetched range (start, end).- Type
- Object
-
<protected> getFetchSize() → {number}
-
Retrieves the fetch size
- Inherited From:
- Source:
Returns:
the fetch size- Type
- number
-
<protected> getIndex(rowKey) → {number}
-
Determine the flattened index for the specified key
Parameters:
Name Type Description rowKeyObject the key to find the index - Inherited From:
- Source:
Returns:
the index representing the specified key. Returns -1 if the index cannot be found.- Type
- number
-
<protected> getKey(index) → {Object|null}
-
Determines the key for the specified flattened index
Parameters:
Name Type Description indexnumber the index in flattened view - Inherited From:
- Source:
Returns:
the key for the specified index. Returns null if the index has not been fetched yet or is invalid.- Type
- Object | null
-
<protected> getMaxCount() → {number}
-
Retrieves the max count
- Inherited From:
- Source:
Returns:
the max count- Type
- number
-
<protected> handleExpandError(rowKey, status)
-
Callback method to handle fetch error on expand operation.
Parameters:
Name Type Description rowKeyObject the key of the expanded row statusObject the error status - Inherited From:
- Source:
-
<protected> handleExpandSuccess(rowKey, nodeSet, childCount, options)
-
Callback method to handle fetch success on expand operation.
Parameters:
Name Type Argument Description rowKeyObject the key of the expanded row nodeSetObject the node set that describes the children of the expanded row childCountnumber the total number of children the expanded row has optionsObject <optional>
optional parameters to the method Properties
Name Type Argument Description queueObject <optional>
a queue of expanded rows remaining to process (depth first traversal) prevNodeSetInfo.nodeSetObject <optional>
the node set from a previous expand call prevNodeSetInfo.firstIndexnumber <optional>
the ref index for the FIRST expand call, this is needed when firing the insert event, where the insertion point is the first index prevNodeSetInfo.firstKeyObject <optional>
the ref row key for the FIRST expand call, this is needed when firing the insert event, where the insertion point is the first row key - Inherited From:
- Source:
-
<protected> handleMaxCountReached(range)
-
Handles the case when the maximum number of rows have been reached
Parameters:
Name Type Description rangeObject the range of the fetch request that cause the max count to be reached Properties
Name Type Description startnumber the start index of the range countnumber the count of the range -
<protected> insertMetadata(key, metadata)
-
A hook for FlattenedTreeDataSource to inject additional metadata into the NodeSet
Parameters:
Name Type Description keyObject the row key identifying the row metadataObject the existing metadata to inject into -
<protected> insertRows(insertAtIndex, insertAtRowKey, nodeSet)
-
Implementation of abstract method to insert a set of rows into the DataGrid
Parameters:
Name Type Description insertAtIndexnumber the flattened index of the node where the rows are inserted. insertAtRowKeyObject the key of the node where the rows are inserted (the parent key) nodeSetObject the node set containing data/metadata of inserted rows -
<protected> refresh()
-
Refresh the data source. Clear out any state.
- Inherited From:
- Source:
-
<protected> removeRows(rowKeys)
-
Implementation of bstract method to remove the specified rows in the DataGrid
Parameters:
Name Type Description rowKeysArray.<Object> an array of keys of the rows to be remove.