Final Class: GroupingDataProvider

Oracle® JavaScript Extension Toolkit (JET)
9.0.0

F24343-01

Signature:

final class GroupingDataProvider<K, D> implements TreeDataProvider<K, D>

QuickNav

GroupingDataProvider

Version:
  • 9.0.0
Module:
  • ojgroupingdataprovider

Module usage

See JET Module Loading for an overview of module usage within JET.

Javascript Import Format
define(['ojs/ojgroupingdataprovider'], function(GroupingDataProvider) {
 // Application should call API on GroupingDataProvider 
})
Typescript Import Format
//This class is exported directly as module. To import it
import GroupingDataProvider= require("ojs/ojgroupingdataprovider");

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.

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.

Description

This class implements oj.TreeDataProvider. Wraps a flat oj.DataProvider and groups the contents into tree data.

Constructor

new GroupingDataProvider(dataProvider, sortComparator, sectionRenderer, options)

Parameters:
Name Type Argument Description
dataProvider DataProvider.<K, D> The oj.DataProvider to be wrapped.

This DataProvider must provide flat data that are sorted in some order.

sortComparator function(D, D): boolean The sort comparator function.

Given two data points, the sortComparator will return true if data2 should be sorted before data1 and false if data2 should be sorted after data1

sectionRenderer function(K): D The section renderer function

This function takes in a section key and returns data that will be provided to the view.

options Object <optional>
the optional parameters.
Properties
Name Type Argument Description
groupByStrategy function(D):Array.<string> The grouping mechanism.

Optional grouping mechanism. This allows for either a grouping function that will take in data and return a path Array of section keys from the root node to the item. The grouping mechanism can also be a string attribute of the data that will contain the path Array of section keys.

keyAttributes string | Array.<string> <optional>
Optional attribute name(s) which stores the key in the data.

Can be a string denoting a single key attribute or an array of strings for multiple key attributes. Dot notation can be used to specify nested attribute (e.g. 'attr.id').

If specified, caller must ensure that the keyAttributes contains values that are either unique within the entire tree, or unique among the siblings of each node. In the latter case, Caller must also set the keyAttributesScope option to 'siblings'.
If keyAttributes is specified and keyAttributesScope is 'global', the attribute value will be used as the key.
If keyAttributes is specified and keyAttributesScope is 'siblings', a path array of the attribute values, starting from the root node, will be used as the key.
If keyAttributes is not specified, a path array of node index, starting from the root node, will be used as the key.

Methods

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

Add a callback function to listen for a specific event type.
Parameters:
Name Type Description
eventType string The event type to listen for.
listener EventListener The callback function that receives the event notification.

containsKeys(params: FetchByKeysParameters<K>): Promise<ContainsKeysResults<K>>

Check if rows are contained by keys (default: local dataset) FetchByKeysParameter scope may be set to "global" to check in global dataset
Parameters:
Name Type Description
params oj.FetchByKeysParameters Fetch by keys parameters
Returns:
Promise which resolves to oj.ContainsKeysResults
Type
Promise.<oj.ContainsKeysResults>

dispatchEvent(evt: Event): boolean

Dispatch an event and invoke any registered listeners.
Parameters:
Name Type Description
event Event The event object to dispatch.
Returns:
Return false if a registered listener has cancelled the event. Return true otherwise.
Type
boolean

fetchByKeys(params: FetchByKeysParameters<K>): Promise<FetchByKeysResults<K, D>>

Fetch rows by keys (default: local dataset)
Parameters:
Name Type Description
params oj.FetchByKeysParameters Fetch by keys parameters
Returns:
Promise which resolves to oj.FetchByKeysResults
Type
Promise.<oj.FetchByKeysResults>

fetchByOffset(params: FetchByOffsetParameters<D>): Promise<FetchByOffsetResults<K, D>>

Fetch rows by offset.
Parameters:
Name Type Description
params oj.FetchByOffsetParameters Fetch by offset parameters
Returns:
Promise which resolves to oj.FetchByOffsetResults
Type
Promise.<oj.FetchByOffsetResults>

fetchFirst(params?: FetchListParameters<D>): AsyncIterable<FetchListResult<K, D>>

Fetch the first block of data.
Parameters:
Name Type Argument Description
params oj.FetchListParameters <optional>
Fetch parameters
See:
Returns:
AsyncIterable with oj.FetchListResult
Type
AsyncIterable.<oj.FetchListResult>

getCapability(capabilityName?: string): any

Determines whether this DataProvider supports certain feature.
Parameters:
Name Type Description
capabilityName string capability name. Supported capability names are: "fetchByKeys", "fetchByOffset", and "sort".
Returns:
capability information or null if unsupported
  • If capabilityName is "fetchByKeys", returns a oj.FetchByKeysCapability object.
  • If capabilityName is "fetchByOffset", returns a oj.FetchByOffsetCapability object.
  • If capabilityName is "sort", returns a oj.SortCapability object.
Type
Object

getChildDataProvider(parentKey: any): GroupingDataProvider<K, D>

Get a data provider for the children of the row identified by parentKey.
Parameters:
Name Type Description
parentKey any key of the row to get child data provider for.
Returns:
An TreeDataProvider if the row can (but doesn't have to) have children; or null if the row cannot have children. Use the isEmpty method on the returned TreeDataProvider to determine if it currently has children.
Type
TreeDataProvider | null

getTotalSize() : {Promise.<number>}

Gets the total size of the data set
Returns:
Returns a Promise which resolves to the total number of rows.
Type
Promise.<number>

isEmpty() : {"yes"|"no"|"unknown"}

Return a string that indicates if this data provider is empty
Returns:
a string that indicates if this data provider is empty. Valid values are: "yes": this data provider is empty. "no": this data provider is not empty. "unknown": it is not known if this data provider is empty until a fetch is made.
Type
"yes" | "no" | "unknown"

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.