Final Class: ArrayTableDataSource

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 1.0
Module:
  • ojarraytabledatasource

Note: This class is deprecated since 5.0.0. Use ArrayDataProvider instead.

QuickNav

Fields

Description

Object representing data available from an array. This data source can be used by ListView, NavigationList, TabBar, and Table.

See the Table - Base Table demo for an example.

Refer to TableDataSource for other data sources that represent tabular 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.


Constructor

new ArrayTableDataSource(data, options)

Parameters:
Name Type Argument Description
data KnockoutObservableArray<object> | Array<object> data supported by the components

This can be either an Array, or a Knockout observableArray.

Each array element should be an object representing one row of data, with the property names and values corresponding to column names and values. Array of primitive values such as ["Apple", "Orange"] is not currently supported.

options Object | null <optional>
Options for the TableDataSource
Properties
Name Type Argument Description
idAttribute string <optional>
The column that contains the row key. If this is not specified, all the values in a row are used as the key.
startFetch "enabled" | "disabled" <optional>
Control whether to start initial fetch when the TableDataSource is bound to a component. Valid values are:

"enabled" (default) - Start initial fetch automatically when the TableDataSource is bound to a component.
"disabled" - Do not start initial fetch automatically. Application will call the fetch() method to start the first fetch.

Fields

comparator :null|string|((param0: object, param1?: object)=> number|string|object)

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
criteria.direction 'ascending' | 'descending' | 'none' the sort direction, valid values are "ascending", "descending", "none" (default)
criteria.key any The key that identifies which field to sort

Methods

add(m, options) : {Promise.<(null|ArrayTableDataSource.RowDatas)>}

Add a row (or array of rows) to the end
Parameters:
Name Type Argument Description
m Object | Array.<Object> Row object data (or array of rows) to add. These should be sets of attribute/values.
options Object <optional>
Properties
Name Type Argument Description
silent boolean <optional>
if set, do not fire an add event

at number | Array.<number> <optional>
splice the new row at the value given (at:index). If an array of rows then this should be an array of indexes

Returns:

Promise object resolves to a compound object which contains an array of row data objects, an array of keys, and an array of indexes which were added triggering done when complete.

The structure of the resolved compound object is:

dataAn array of raw row data
keysAn array of key values for the rows
indexesAn array of index values for the rows

Type
Promise.<(null|ArrayTableDataSource.RowDatas)>

at(index, options) : {Promise.<(null|TableDataSource.RowData)>}

Return the row data found at the given index.
Parameters:
Name Type Argument Description
index number Index for which to return the row data.
options Object <optional>
Options to control the at.
Returns:

Promise resolves to a compound object which has the structure below. If the index is out of range, Promise resolves to null.

dataThe raw row data
indexThe index for the row
keyThe key value for the row

Type
Promise.<(null|TableDataSource.RowData)>

change(m, options) : {Promise.<(null|ArrayTableDataSource.RowDatas)>}

Change a row (or array of rows), if found.
Parameters:
Name Type Argument Description
m Object | Array.<Object> Row object data (or array of rows) to change. These should be sets of attribute/values.
options Object <optional>
Properties
Name Type Argument Description
silent boolean <optional>
if set, do not fire an add event

Returns:

Promise object resolves to a compound object which contains an array of row data objects, an array of keys, and an array of indexes which were changed triggering done when complete.

The structure of the resolved compound object is:

dataAn array of raw row data
keysAn array of key values for the rows
indexesAn array of index values for the rows

Type
Promise.<(null|ArrayTableDataSource.RowDatas)>

fetch(options) : {Promise.<(null|TableDataSource.RowDatas)>}

Fetch the row data.
Parameters:
Name Type Argument Description
options Object <optional>
Options to control fetch
Properties
Name Type Argument Description
startIndex number <optional>
The index at which to start fetching records.
silent boolean <optional>
If set, do not fire a sync event.
Returns:

Promise object resolves to a compound object which contains an array of row data objects, an array of ids, and the startIndex triggering done when complete.

The structure of the resolved compound object is:

dataAn array of raw row data
keysAn array of key values for the rows
startIndexThe startIndex for the returned set of rows

Type
Promise.<(null|TableDataSource.RowDatas)>

get(id, options) : {Promise.<(null|TableDataSource.RowData)>}

Return the first row data whose id value is the given id
Parameters:
Name Type Argument Description
id string ID for which to return the row data, if found.
options Object <optional>
Options to control the get.
Returns:

Promise which resolves to a compound object which has the structure below where the id matches the given id. If none are found, resolves to null.

dataThe raw row data
indexThe index for the row
keyThe key value for the row

Type
Promise.<(null|TableDataSource.RowData)>

getCapability(feature) : {string|null}

Determines whether this TableDataSource supports certain feature.
Parameters:
Name Type Description
feature string 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". Returns null if the feature is not recognized.

Type
string | null

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 : {undefined}

Initializes the instance.
Inherited From:
Returns:
Type
undefined

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

remove(m, options) : {Promise.<(null|ArrayTableDataSource.RowDatas)>}

Remove a row (or array of rows), if found.
Parameters:
Name Type Argument Description
m Object | Array.<Object> Row object data (or array of rows) to remove. These should be sets of attribute/values.
options Object <optional>
Properties
Name Type Argument Description
silent boolean <optional>
if set, do not fire a remove event
Returns:

Promise object resolves to a compound object which contains an array of row data objects, an array of keys, and an array of indexes which were removed triggering done when complete.

The structure of the resolved compound object is:

dataAn array of raw row data
keysAn array of key values for the rows
indexesAn array of index values for the rows

Type
Promise.<(null|ArrayTableDataSource.RowDatas)>

reset(data, options) : {Promise.<void>}

Remove and replace the entire list of rows with a new set of rows, if provided. Otherwise, empty the datasource. The next fetch call will re-populate the datasource with the original array data. To empty out the data, call reset with an empty array.
Parameters:
Name Type Argument Description
data Array.<Object> <optional>
Array of row objects with which to replace the data.
options Object <optional>
user options, passed to event
Returns:

promise object triggering done when complete.

Type
Promise.<void>

sort(criteria) : {Promise.<null>}

Performs a sort on the data source.
Parameters:
Name Type Argument Description
criteria Object | null <optional>
the sort criteria.
Properties
Name Type Description
key any The key that identifies which field to sort
direction 'ascending' | 'descending' | 'none' the sort direction, valid values are "ascending", "descending", "none" (default)
Returns:

promise object triggering done when complete.

Type
Promise.<null>

totalSize : {number}

Return the total size of data available, including server side if not local.
Returns:

total size of data

Type
number

totalSizeConfidence : {('actual'|'estimate'|'atLeast'|'unknown')}

Returns the confidence for the totalSize value.
Inherited From:
Returns:

"actual" if the totalSize is the time of the fetch is an exact number "estimate" if the totalSize is an estimate "atLeast" if the totalSize is at least a certain number "unknown" if the totalSize is unknown

Type
('actual'|'estimate'|'atLeast'|'unknown')

Type Definitions

RowDatas

Shape of Data Info returned by methods like, add/change/remove.
Properties:
Name Type Description
data Array.<Object> An array of raw row data.
indexes Array.<number> An array of index values for the rows.
keys Array.<any> An array of key values for the rows.