Class: ArrayDataGridDataSource

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

QuickNav

Fields


ArrayDataGridDataSource extends oj.DataGridDataSource

Version:
  • 7.1.0
Since:
  • 1.0
Module:
  • ojarraydatagriddatasource

Module usage

See JET Module Loading for an overview of module usage within JET.

Javascript Import Format
define(['ojs/ojarraydatagriddatasource'], function(arraydatagriddatasource) {
 // Application should call API on arraydatagriddatasource.ArrayDataGridDataSource 
})

Description

An array based implementation of the DataGridDataSource.
Properties:
Name Type Argument Description
options.columns Array.<any> <optional>
an array of columns to return as column headers.
options.rowHeader any <optional>
an object representing the default row header, if a string is provided it will be used as the key of the header, if a number is provided it will be used as the index of the header.
Properties
Name Type Argument Description
default string <optional>
disable default row headers or provide them as indexes 'none' or 'index'
options.initialSort Object <optional>
the information about the array if it is pre-sorted
Properties
Name Type Argument Description
axis string <optional>
the axis that the array is sorted on valid values are 'column', 'row'
key any <optional>
the key that the array is sorted on
direction string <optional>
valid values are ascending or descending

Constructor

new ArrayDataGridDataSource(data, options)

Parameters:
Name Type Argument Description
data Array | Object the data in the form of array or observable array.
options Object <optional>
the options specific to this DataGridDataSource.
Properties:
Name Type Argument Description
options.columns Array.<any> <optional>
an array of columns to return as column headers.
options.rowHeader any <optional>
an object representing the default row header, if a string is provided it will be used as the key of the header, if a number is provided it will be used as the index of the header.
Properties
Name Type Argument Description
default string <optional>
disable default row headers or provide them as indexes 'none' or 'index'
options.initialSort Object <optional>
the information about the array if it is pre-sorted
Properties
Name Type Argument Description
axis string <optional>
the axis that the array is sorted on valid values are 'column', 'row'
key any <optional>
the key that the array is sorted on
direction string <optional>
valid values are ascending or descending

Fields

comparator :Function

If set to a function(row1, row2), then this function is called comparing raw row data (see the JavaScript array.sort() for details)

sortCriteria :Object

The sort criteria. Whenever sort() is called with the criteria parameter, that value is copied to this property. If sort() is called with empty sort criteria then the criteria set in this property is used.
Properties:
Name Type Description
axis string the sort axis valid values are "column", "row"
key string | number The key that identifies which field to sort
direction string the sort direction, valid values are "ascending", "descending", "none" (default)

Methods

fetchCells(cellRanges, callbacks, callbackObjects)

Fetch a range of cells from the data source.
Parameters:
Name Type Argument Description
cellRanges Array.<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.
callbacks Object the callbacks to be invoke when fetch cells operation is completed.
callbackObjects Object <optional>
the object in which the callback function is invoked on.
Properties:
Name Type Argument Description
cellRanges.axis string the axis associated with this range where cells are fetched. Valid values are "row" and "column".
cellRanges.start number the start index of the range for this axis in which the cells are fetched.
cellRanges.count number the size of the range for this axis in which the cells are fetched.
callbacks.success function({cellSet: Object}, {cellRanges: Array.<Object>}):undefined the callback to invoke when fetch cells completed successfully.
callbacks.error function({status: Object}):undefined the callback to invoke when fetch cells failed.
callbackObjects.success Object <optional>
callbackObjects.error Object <optional>

fetchHeaders(headerRange, callbacks, callbackObjects) → {undefined}

Fetch a range of headers from the data source.
Parameters:
Name Type Argument Description
headerRange Object information about the header range, it must contain the following properties: axis, start, count.
callbacks Object the callbacks to be invoke when fetch headers operation is completed.
callbackObjects Object <optional>
the object in which the callback function is invoked on.
Properties:
Name Type Argument Description
headerRange.axis string the axis of the header that are fetched. Valid values are "row" and "column".
headerRange.start number the start index of the range in which the header data are fetched.
headerRange.count number the size of the range in which the header data are fetched.
callbacks.success function({startHeaderSet: Object}, {headerRange: Object}, {endHeaderSet: Object}):undefined the callback to invoke when fetch headers completed successfully. The function takes three parameters: HeaderSet object representing start headers, headerRange object passed into the original fetchHeaders call, and a HeaderSet object representing the end headers along the axis.
callbacks.error function({status: Object}):undefined the callback to invoke when fetch cells failed.
callbackObjects.success Object <optional>
callbackObjects.error Object <optional>
Returns:
Type
undefined

getCapability(feature) → {string|null}

Determines whether this ArrayDataGridDataSource supports certain feature.
Parameters:
Name Type Description
feature string the feature in which its capabilities is inquired. Currently the only valid feature is "sort" and "move"
Returns:
the name of the feature. For sort, the valid return values are: "full", "none". 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
axis string 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
axis string 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

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

indexes(keys) → {Promise.<Object>}

Returns the row and column index based on the keys. In a paging case returns the index on the page, not the absolute index in the array.
Parameters:
Name Type Description
keys Object the key for each axis
Properties:
Name Type Description
keys.row any the key for the row axis
keys.column any the key for the column axis
Returns:
a promise object containing the index for each axis
Type
Promise.<Object>

Init() → {undefined}

Initializes the instance.
Inherited From:
Returns:
Type
undefined

keys(indexes) → {Promise.<Object>}

Returns the keys based on the indexes.
Parameters:
Name Type Description
indexes Object the index for each axis
Properties:
Name Type Description
indexes.row number | null the index for the row axis
indexes.column number | null the index for the column axis
Returns:
a Promise object which upon resolution will pass in an object containing the keys for each axis
Type
Promise.<Object>

move(rowToMove, referenceRow, position, callbacks, callbackObjects) → {undefined}

Moves a row from one location to another.
Parameters:
Name Type Argument 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 string The position of the moved row relative to the reference row. Valid values are: "before", "after"
callbacks Object <optional>
the callbacks to be invoke upon completion of the move operation.
callbackObjects Object <optional>
the object in which the callback function is invoked on.
Properties:
Name Type Argument Description
callbacks.success function():undefined the callback to invoke when the sort completed successfully.
callbacks.error function({status: Object}):undefined the callback to invoke when sort failed.
callbackObjects.success Object <optional>
callbackObjects.error Object <optional>
Returns:
Type
undefined

moveOK(rowToMove, referenceRow, position) → {string}

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 string The position of the moved row relative to the reference row. Valid values are: "before", "after".
Returns:
returns "valid" if the move is valid, "invalid" otherwise.
Type
string

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, callbackObjects) → {undefined}

Performs a sort on the data source.
Parameters:
Name Type Argument Description
criteria Object | null the sort criteria.
callbacks Object <optional>
the callbacks to be invoke upon completion of the sort operation.
callbackObjects Object <optional>
the object in which the callback function is invoked on.
Properties:
Name Type Argument Description
criteria.axis string The axis in which the sort is performed, valid values are "row", "column"
criteria.key any The key that identifies which header to sort
criteria.direction string the sort direction, valid values are "ascending", "descending", "none" (default)
callbacks.success function():undefined the callback to invoke when the sort completed successfully.
callbacks.error function({status: Object}):undefined the callback to invoke when sort failed.
callbackObjects.success Object <optional>
callbackObjects.error Object <optional>
Returns:
Type
undefined