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
(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:
data An array of raw row data keys An array of key values for the rows indexes An array of index values for the rows in post-insert sorted order CHANGE
string change Triggered when a Row's attributes have been changed The event payload contains:
data An array of raw row data keys An array of key values for the rows indexes An array of index values for the rows ERROR
string error Triggered when an error occurred on the TableDataSource REFRESH
string refresh Triggered when a TableDataSource has been refreshed REMOVE
string remove Triggered when a Row has been removed from a TableDataSource The event payload contains:
data An array of raw row data keys An array of key values for the rows indexes An array of index values for the rows in pre-remove sorted order 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: startIndex The start index at which the fetch was invoked RESET
string reset Triggered when a TableDataSource has been reset SORT
string sort Triggered when a TableDataSource has been sorted The event payload contains:
header the key of the header which was sorted on direction the direction of the sort ascending/descending 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:
data An array of raw row data keys An array of key values for the rows startIndex The start index at which the fetch occurred -
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
-
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.
data The raw row data index The index for the row key The key value for the row - Type
- Promise.<(null|TableDataSource.RowData)>
-
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 options.silent
boolean <optional>
If set, do not fire a sync event. options.startIndex
number <optional>
The index at which to start fetching records. 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:
data An array of raw row data keys An array of key values for the rows startIndex The 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.
data The raw row data index The index for the row key The 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
-
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.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 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.
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
-
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
any 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.<any> An array of key values for the rows. startIndex
number The startIndex for the returned set of rows.