Class: TableDataSource

Oracle® JavaScript Extension Toolkit (JET)
5.0.0

E90577-01

QuickNav

Fields

TableDataSource extends oj.DataSource

Version:
  • 5.0.0
Since:
  • 1.0
Module:
  • ojdatasource-common
Abstract class representing tabular data that can be used by different components such as ListView, NavigationList, PagingControl, TabBar, and Table.

This class is not used directly and is used as the base to implement other subclasses. Implementations of TableDataSource must implement all of the methods documented here.

JET provides the following implementations:

Subclass When to Use Use with
oj.ArrayTableDataSource When the data is available from an array. ListView
NavigationList
TabBar
Table
oj.CollectionTableDataSource When the data is available from an oj.Collection object, such as an external data source. ListView
NavigationList
TabBar
Table
oj.FlattenedTreeTableDataSource When the data has a tree-like structure that is displayed in a Table with RowExpander. Table (with RowExpander)
oj.PagingTableDataSource When paging functionality is needed on top of other TableDataSource implementations. ListView
PagingControl
Table

Refer to the documentation and demos of individual components for more information on how to use them with the TableDataSource subclasses.

In case specialized behavior is needed, new subclass can be created by using oj.Object.createSubclass. New subclass can be based on TableDataSource, in which case all methods must be implemented, or it can be based on an existing subclass, in which case only methods that require different behavior need to be overridden.

Constructor

(abstract) new TableDataSource(data, options)

Parameters:
Name Type Argument Description
data Object data supported by the components
options Object <optional>
Options for the TableDataSource

Fields

(static) EventType :string

Events which are published by TableDataSource. Any custom TableDataSource implementation must publish the corresponding events.
Properties:
Name Type Default Description
ADD string add Triggered when a Row has been added to a TableDataSource

The event payload contains:

dataAn array of raw row data
keysAn array of key values for the rows
indexesAn array of index values for the rows in post-insert sorted order

REMOVE string remove Triggered when a Row has been removed from a TableDataSource

The event payload contains:

dataAn array of raw row data
keysAn array of key values for the rows
indexesAn array of index values for the rows in pre-remove sorted order

RESET string reset Triggered when a TableDataSource has been reset
REFRESH string refresh Triggered when a TableDataSource has been refreshed
SORT string sort Triggered when a TableDataSource has been sorted

The event payload contains:

headerthe key of the header which was sorted on
directionthe direction of the sort ascending/descending

CHANGE string change Triggered when a Row's attributes have been changed

The event payload contains:

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

REQUEST string request Triggered when a TableDataSource has sent a fetch request. It is expected that a component using TableDataSource will go into a busy state upon receiving this event. The event payload contains:

startIndexThe start index at which the fetch was invoked

SYNC string sync Triggered when a TableDataSource has been updated by a fetch. It is expected that a component using TableDataSource will exit busy state upon completion of rendering after receiving this event.

The event payload contains:

dataAn array of raw row data
keysAn array of key values for the rows
startIndexThe start index at which the fetch occurred

ERROR string error Triggered when an error occurred on the TableDataSource

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

Methods

at(index, options) → {Promise.<(null|oj.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|oj.TableDataSource.RowData)>

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

Fetch the row data.
Parameters:
Name Type Argument Description
options Object <optional>
Options to control fetch
Properties:
Name Type Argument Description
options.startIndex number <optional>
The index at which to start fetching records.
options.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|oj.TableDataSource.RowDatas)>

get(id, options) → {Promise.<(null|oj.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|oj.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

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

Performs a sort on the data source. Null criteria clears the existing sort.
Parameters:
Name Type Argument Description
criteria Object <optional>
the sort criteria.
Properties:
Name Type Description
criteria.key * The key that identifies which field to sort
criteria.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() → {string}

Returns the confidence for the totalSize value.
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
string

Type Definitions

RowData

Row Data returned by methods like, at/get.
Properties:
Name Type Description
data Object The raw row data.
index number The index for the row.
key * The key value for the row.

RowDatas

Row Datas returned by fetch method.
Properties:
Name Type Description
data Array.<Object> An array of raw row data.
keys Array.<*> An array of key values for the rows.
startIndex number The startIndex for the returned set of rows.