Usage
Signature:
class RowDataGridProvider<D, K, R> implements DataGridProvider<{data: D}>
Generic Parameters
Parameter Description D Type of Data Returned in fetchByOffset K Type of Key in the underlying DataProvider R Type 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.<D, 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
- If capabilityName is "version", returns a VersionCapability object.
- Type
- any
Example
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
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. -
updateItemMetadata(ranges: DataGridProviderUpdateOperationEventDetail['ranges']): void
-
Update metadata of cells by range. This method should be called by the application when the return values of the metadataCallback have changed without an underlying data change. Avoid calling this method when an underlying data change coincides with a metadata change.
Parameters:
Name Type Description ranges
DataGridProviderUpdateOperationEventDetail.ranges - Since:
- 16.0.0
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. -
ItemMetadata<D, K, R>
-
Used to specify callbacks to override individual header/cell metadata. This enables metadata driven features on the DataGrid such as sort icons, filtering, expand/collapse, required, validity and future improvements. The object that is returned for each sub-property will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are name-spaced by applications to avoid conflicting with future supported properties.
Properties:
Name Type Argument Description columnEndHeader
(item: GridHeaderItem<D>) => GridHeaderMetadata <optional>
A callback to supply metadata for column-end headers. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. columnEndHeaderLabel
(item: GridItem<D>) => GridItemMetadata <optional>
A callback to supply metadata for column-end headerLabels. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. columnHeader
(item: GridHeaderItem<D>) => GridHeaderMetadata <optional>
A callback to supply metadata for column headers. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. columnHeaderLabel
(item: GridItem<D>) => GridItemMetadata <optional>
A callback to supply metadata for column headerLabels. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. databody
(item: GridBodyItem<D>) => RowDataGridProvider.GridBodyItemMetadata<K,R> <optional>
A callback to supply metadata for the databody cells. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. rowEndHeader
(item: GridHeaderItem<D>) => GridHeaderMetadata <optional>
A callback to supply metadata for row-end headers. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. rowEndHeaderLabel
(item: GridItem<D>) => GridItemMetadata <optional>
A callback to supply metadata for row-end headerLabels. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. rowHeader
(item: GridHeaderItem<D>) => GridHeaderMetadata <optional>
A callback to supply metadata for row headers. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. rowHeaderLabel
(item: GridItem<D>) => GridItemMetadata <optional>
A callback to supply metadata for row headerLabels. The object that is returned will be merged into the existing metadata, with precedence given to the returned object. It is recommended that any non-documented metadata properties are namespaced by applications to avoid conflicting with future supported properties. -
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<D, K, R>
-
The initialization options for the RowDataGridProvider. Used to specify the structure to display the underlying DataProvider in.
- Deprecated:
-
Since Description 16.1.0
The filterable property is deprecated. Applications should instead specify the ItemMetadata.columnHeader callback to pass in filter information. - Deprecated:
-
Since Description 16.1.0
The sortable property is deprecated. Applications should instead specify the ItemMetadata.columnHeader callback to pass in sort information.
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. filterable
boolean <optional>
A boolean true if the data grid provider is filterable. headerLabels
RowDataGridProvider.HeaderLabels<R> <optional>
An object defining the row, row end, column and column end header labels. itemMetadata
RowDataGridProvider.ItemMetadata.<D, K, R> <optional>
Used to specify callbacks to override individual header/cell metadata. This enables metadata driven features on the DataGrid such as sort icons, filtering, expand/collapse, required, validity and future improvements. 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>