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 ADDstring 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 CHANGEstring 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 ERRORstring error Triggered when an error occurred on the TableDataSource REFRESHstring refresh Triggered when a TableDataSource has been refreshed REMOVEstring 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 REQUESTstring 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 RESETstring reset Triggered when a TableDataSource has been reset SORTstring 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 SYNCstring 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.keyany 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 indexnumber Index for which to return the row data. optionsObject <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 optionsObject <optional>
Options to control fetch Properties:
Name Type Argument Description options.silentboolean <optional>
If set, do not fire a sync event. options.startIndexnumber <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 idstring ID for which to return the row data, if found. optionsObject <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 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". Returns null if the feature is not recognized.
- Type
- string | null
-
handleEvent(eventType, event) : {boolean}
-
Handle the event
Parameters:
Name Type Description eventTypestring event type eventObject 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
onmethod.Parameters:
Name Type Description eventTypestring eventType eventHandlerfunction(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
offmethod to detach the handler when it no longer wants to be notified.Parameters:
Name Type Description eventTypestring eventType eventHandlerfunction(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 criteriaObject <optional>
the sort criteria. Properties:
Name Type Description criteria.direction'ascending' | 'descending' | 'none' the sort direction, valid values are "ascending", "descending", "none" (default) criteria.keyany 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 dataObject The raw row data. indexnumber The index for the row. keyany The key value for the row. -
RowDatas
-
Row Datas returned by fetch method.
Properties:
Name Type Description dataArray.<Object> An array of raw row data. keysArray.<any> An array of key values for the rows. startIndexnumber The startIndex for the returned set of rows.