define(['ojs/ojindexermodeltreedataprovider'], function(IndexerModelTreeDataProvider) {
// Application should call API on IndexerModelTreeDataProvider
})
Typescript Import Format
//This class is exported directly as module. To import it import IndexerModelTreeDataProvider= require("ojs/ojindexermodeltreedataprovider");
Generic Parameters
Parameter
Description
K
Type of Key
D
Type of Data
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
TreeDataProvider and IndexerModel implementation that represents hierachical data available from an array of JSON objects. This DataProvider can be used by Indexer and
its associated ListView.
Refer to oj.TreeDataProvider for other data providers that represent hierarachical data.
Constructor
new IndexerModelTreeDataProvider(data, options)
Implementation of the IndexerModel and TreeDataProvider based on an array of data set.
This should be used with the Indexer and its associated ListView.
By default, this DataProvider groups the data based on the first letter of the data and the alphabet of the current locale.
Note this implementation of TreeDataProvider does not fire any model events.
the field of the data that uniquely identifies the data. Can be a string denoting a single key attribute or an array of strings for multiple key attributes.
If not specified, then one will be created.
sections
Array.<string>
|
Array.<Object>
<optional>
the set of sections to use with the Indexer. If not specified, then the sections are derived from the alphabet of the current locale.
a callback function that handles when a section becomes current (user clicks on the section in the Indexer).
the function takes the section that is going to become current and must return a Promise which when resolve returns the section that actually becomes current.
groupingAttribute
string
<optional>
the attribute of the data where grouping is based on, mandatory if no groupingStrategy is specified.
a callback function that takes a data and returns the section that the data belongs to. If no groupingStrategy is specified,
then the default grouping strategy based on the first letter of the data is used.
sortComparators
ArrayDataProvider.SortComparators<D>
<optional>
a comparator function that is used to sort data within a section.
A 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.
Returns an array of objects each representing a section that does not have a corresponding section in the associated ListView.
It must be a subset of the return value of getIndexableSections. Return null or undefined if there's nothing missing.
Returns:
an array of missing sections
Type
Array.<string>
|
Array.<Object>
getTotalSize() : {Promise.<number>}
Return the total number of rows in this IndexerModelTreeDataProvider.
Returns:
Returns a Promise which resolves to the total number of rows. -1 is unknown row count.
Type
Promise.<number>
isEmpty(): 'yes' | 'no' | 'unknown'
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.
Returns:
string that indicates if this data provider is empty
a Promise which when resolved will return the section that the associated ListView actually scrolls to.
For example, the implementation could choose to scroll to the next available section in ListView if no data
exists for the current section section.