Usage
Signature:
final class GroupingDataProvider<K, D> implements TreeDataProvider<K, D>
Typescript Import Format
//This class is exported directly as module. To import it
import GroupingDataProvider= require("ojs/ojgroupingdataprovider");
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
new GroupingDataProvider(dataProvider, sortComparator, sectionRenderer, options)
Parameters:
Name | Type | Argument | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dataProvider |
DataProvider.<K, D> | The 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
|
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:
-
- https://github.com/tc39/proposal-async-iteration for further information on AsyncIterable.
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 theisEmpty
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.