Class: RowDataGridProvider

Oracle® JavaScript Extension Toolkit (JET)
15.1.0

F83698-01

Since:
  • 13.0.0
Module:
  • ojrowdatagridprovider

QuickNav

Description

This class implements DataGridProvider.

This class transforms a DataProvider implementation into a DataGridProvider for use with the ojDataGrid. Each ojDataGrid should get its own instance of a RowDataGridProvider.

Being DataProvider based means that this class only implements fetch virtualization in the row direction. The DataGrid component view will still virtualize rendering in both column and row directions, but this class will fetch the whole row as the user scrolls down.

Along similar lines this means that some DataGrid features are not supported by this class. Row grouping via nested row headers is not supported. Merge cells is not supported. Expand/Collapse and showRequired of column headers is not yet supported.

The RowDataGridProvider performance is dependent on the implementation of the underlying DataProvider and it fetchByOffset implementation. For best performance results the underlying DataProvider should support fetchByOffset with a implementation capability of randomAccess. In addition using fetchByOffset caching will also improve performance.

The RowDataGridProvider will provide data in the GridItem's returned by fetchByOffset as objects with sub-property data set to the data retrieved from the underlying DataProvider Items. This will mean in inspecting the data attribute applications will need to reference Item.data.data.

The RowDataGridProvider will provide the underlying DataProvider Item to each cell and row header in a row on the Item.metadata.rowItem attribute.


Usage

Signature:

class RowDataGridProvider<D, K, R> implements DataGridProvider<{data: D}>

Generic Parameters
ParameterDescription
DType of Data Returned in fetchByOffset
KType of Key in the underlying DataProvider
RType of Row Data in the underlying DataProvider
Typescript Import Format
//To import this class, use the format below.
import {RowDataGridProvider} from "ojs/ojrowdatagridprovider";

For additional information visit:


Constructor

new RowDataGridProvider(dataProvider, options)

Parameters:
Name Type Argument Description
dataProvider DataProvider.<K, R> The underlying DataProvider.
options RowDataGridProvider.Options.<K, R> <optional>
The initialization options for the RowDataGridProvider. Used to specify the structure to display the underlying DataProvider in.

Methods

addEventListener(eventType: string, listener: EventListener): void

Add a callback function to listen for a specific event type. Currently supported events are DataGridProviderRefreshEvent, DataGridProviderAddEvent, DataGridProviderRemoveEvent, and DataGridProviderUpdateEvent.
Parameters:
Name Type Description
eventType string The event type to listen for.
listener EventListener The callback function that receives the event notification.

fetchByOffset(parameters: FetchByOffsetGridParameters): Promise<FetchByOffsetGridResults<{data:D}>>

Fetch data for specified fetch regions by offset and count.

Parameters passed in will indicate which regions of the data to fetch.

Inspect FetchByOffsetGridParameters and FetchByOffsetGridResults for details on expected values.

The results for the fetch should contain every item which is within the bounds of the fetch at all. This includes header or cell items that have extents that cross the boundary of the fetch.

Results allows for categorical iteration of fetch regions, but not offset/count iteration, via the next property.

If a the DataGridProvider supports mutations it should implement a versioning strategy to indicate the version of returned result set.

Parameters:
Name Type Description
parameters FetchByOffsetGridParameters fetch by offset parameters
Since:
  • 11.0.0
Returns:

Returns Promise which resolves to FetchByOffsetGridResults.

Type
Promise.<FetchByOffsetGridResults>

getCapability(capabilityName: string): any

Determines whether this DataGridProvider defines a certain feature.
Parameters:
Name Type Description
capabilityName string capability name. Defined capability names are: "version".
Since:
  • 11.0.0
Returns:

capability information or null if undefined

Type
any
Example

Check what kind of fetchByKeys is defined.

let capabilityInfo = dataGridProvider.getCapability('version');
if (capabilityInfo.implementation == 'monotonicallyIncreasing') {
  // the DataGridProvider supports monotonicallyIncreasing for version
  ...

isEmpty(): 'yes' | 'no' | 'unknown'

Returns a string that indicates if this DataGridProvider is empty. Valid values are:
  • "yes": this DataGridProvider is empty.
  • "no": this DataGridProvider is not empty.
  • "unknown": it is not known if this DataGridProvider is empty until a fetch is made.
Since:
  • 11.0.0
Returns:

string that indicates if this DataGridProvider is empty

Type
"yes" | "no" | "unknown"
Example

Check if empty

let isEmpty = dataGridProvider.isEmpty();
console.log('DataGridProvider is empty: ' + isEmpty);

removeEventListener(eventType: string, listener: EventListener): void

Remove a listener previously registered with addEventListener.
Parameters:
Name Type Description
eventType string The event type that the listener was registered for.
listener EventListener The callback function that was registered.

Type Definitions

ColumnHeaderLabelsFunction<R>

A callback function used to declare the column header labels of the grid. Accepts the column headers as parameters and returns an array of strings representing the data in the column header labels. The returned array is ordered from innermost to outermost header label.
Signature:

(headers: Array<RowDataGridProvider.NestedHeader>) => Array<string>

ColumnHeaders<R>

Properties:
Name Type Argument Description
column 'attributeName' | Array<string> | Array<RowDataGridProvider.NestedHeader> | RowDataGridProvider.ColumnHeadersFunction<R> <optional>
Defines the structure of the start column headers
columnEnd 'attributeName' | Array<string> | Array<RowDataGridProvider.NestedHeader> | RowDataGridProvider.ColumnHeadersFunction<R> <optional>
Defines the structure of the end column headers

ColumnHeadersFunction<R>

A callback function used to declare the column headers of the grid. Accepts the data body column keys as parameters and returns an array of of Nested Header objects representing the data and structure in the column headers.
Signature:

(columns: Array<keyof R>) => Array<RowDataGridProvider.NestedHeader>

Columns<K,R>

An object defining the columns in the row headers, data body, and row end headers. If not set the provider will extract the columns from the first row and assign all of them to the data body region.
Properties:
Name Type Argument Description
databody Array<keyof R> | RowDataGridProvider.ColumnsFunction<K,R> <optional>
Defines the columns to be displayed in the databody from start to end as an array of keys contained by the row items in the data provider. If a column key is not present in a row item, the data for that cell will be returned as undefined. If not set the column keys will be derived from the first row item returned by the data provider, filtering out keys contained by rowHeader or rowEndHeader and assigning them in the order returned by Object.keys to the databody region. Specify a function to dynamically pick columns from the first row item of the underlying data provider.
rowEndHeader Array<keyof R> | RowDataGridProvider.ColumnsFunction<K,R> <optional>
Defines the columns to be displayed in the row end headers from start to end as an array of keys contained by the row items in the data provider. If a column key is not present in a row item, the data for that cell will be returned as undefined.
rowHeader Array<keyof R> | RowDataGridProvider.ColumnsFunction<K,R> <optional>
Defines the columns to be displayed in the row headers from start to end as an array of keys contained by the row items in the data provider. If a column key is not present in a row item, the data for that cell will be returned as undefined.

ColumnsFunction<K, R>

A function used to pick and order the columns of the regions of the data grid. This function accepts the first item of data fetched and returns an array of keys inside the data of the item.
Signature:

(firstItem: Item<K,R>) => Array<keyof R>

HeaderLabels<R>

An object defining the data in the header labels.
Properties:
Name Type Argument Description
column Array<string> | RowDataGridProvider.ColumnHeaderLabelsFunction<R> <optional>
A flat list for single extent column header labels. An array or callback function based on the column headers is used to set custom label data.
columnEnd Array<string> | RowDataGridProvider.ColumnHeaderLabelsFunction<R> <optional>
A flat list for single extent column end header labels. An array or callback function based on the column end headers is used to set custom label data.
row 'attributeName' | Array<string> | RowDataGridProvider.RowHeaderLabelsFunction<R> <optional>
Opt-in to specifying single extent row header labels. Setting 'attributeName' will result in row header labels where data in the header label cells is the key of the column from the RowDataGridProvider.Columns.rowHeader definition. An array or callback function can be used to set custom label data.
rowEnd 'attributeName' | Array<string> | RowDataGridProvider.RowHeaderLabelsFunction<R> <optional>
Opt-in to specifying single extent row end header labels. Setting 'attributeName' will result in row end header labels where data in the header label cells is the key of the column from the RowDataGridProvider.Columns.rowEndHeader definition. An array or callback function can be used to set custom label data.

NestedHeader

An object defining a hierarchical structure of nested column headers. The extent of a header will be computed as the sum of its innermost children.
Properties:
Name Type Argument Description
children ?Array<RowDataGridProvider.NestedHeader> <optional>
An array of children headers
data string <optional>
The data to return to the DataGrid for this header
depth number <optional>
The depth of the header, meaning how many levels the header spans, the default if unspecified is 1

Options<K, R>

The initialization options for the RowDataGridProvider. Used to specify the structure to display the underlying DataProvider in.
Properties:
Name Type Argument Description
columnHeaders RowDataGridProvider.ColumnHeaders<R> <optional>
An object defining the column and column end headers.
columns RowDataGridProvider.Columns<K, R> <optional>
An object defining the columns in the row headers, data body, and row end headers.
expandedObservable {subscribe( subscriber : ((expanded: {value: KeySet<K>, completionPromise: Promise<any>}) => void) ): {unsubscribe(): void, closed(): boolean}} <optional>
An observable tracking the expansion state of the underlying data provider.
headerLabels RowDataGridProvider.HeaderLabels<R> <optional>
An object defining the row, row end, column and column end header labels.
sortable boolean <optional>
A boolean true if the data grid provider is sortable.

RowHeaderLabelsFunction<R>

A callback function used to declare the row header labels of the grid. Accepts the row header column keys as parameters and returns an array of strings representing the data in the row header labels. The returned array is ordered from innermost to outermost header label.
Signature:

(columns: Array<keyof R>) => Array<string>