API / geotoolkit / data / DataTableView / DataTableView
data.DataTableView.DataTableView
A read-only view of an underlying DataTable. A DataTableView allows selection of only a subset of the columns. It also allows reordering columns and duplicating columns.
A DataTableView is a "view" of a datasource DataTable . To add data, you will have to do so to the original DataTable.
Please refer to the example below for a way to create and use DataTableView.
Example
import {DataTableView} from '@int/geotoolkit/data/DataTableView';
import {DataTable} from '@int/geotoolkit/data/DataTable';
...
//Create a DataTable
const dataTable = new DataTable({ 'cols': [
{'type': 'number', 'data': indicesArray},
{'type': 'number', 'data': valuesArray}
]});
dataTable.getColumn(0).setUnit(indexunit);
dataTable.getColumn(1).setUnit(valueunit);
// Create a DataTableView of the DataTable
const dataTableView = new DataTableView(dataTable);
// user can modify the data in the original DataTable using the API of the DataTable
// addRow, addRows, removeRow, insertRow↳
DataTableView
Constructors
Methods
Constructors
• new DataTableView(dataTable)
| Name | Type |
|---|---|
dataTable | AbstractDataTable |
AbstractDataTable.constructor
Methods
▸ dispose(): void
Dispose data table view object.
void
▸ getClassName(): string
string
AbstractDataTable.getClassName
▸ getColumn(columnIndex): DataSeriesView<any>
Return column by index
| Name | Type | Description |
|---|---|---|
columnIndex | number | index of the column |
DataSeriesView<any>
a column
▸ getColumnById(id): AbstractDataSeries<any>
Return column by column id
| Name | Type | Description |
|---|---|---|
id | string | number | column id |
AbstractDataSeries<any>
a column of null if column is not found
AbstractDataTable.getColumnById
▸ getColumnByName(name): AbstractDataSeries<any>
Return column by name
| Name | Type | Description |
|---|---|---|
name | string | nam eof the column |
AbstractDataSeries<any>
the first column with specified name or null if column is not found
AbstractDataTable.getColumnByName
▸ getColumnProperties(columnIndex): Record<string, any>
Returns the map of all properties of specified column.
| Name | Type | Description |
|---|---|---|
columnIndex | number | index of the column |
Record<string, any>
AbstractDataTable.getColumnProperties
▸ getDataTable(): AbstractDataTable
Get parent data table, which is used to create the current view
data table
▸ getMetaData(): Record<string, any>
Returns the map of all meta data of the data table. This method returns the reference to the meta data.
Record<string, any>
meta data
▸ getName(): string
Returns table name
string
▸ getNumberOfColumns(): number
Returns number of columns in the view
number
number of columns in the view
AbstractDataTable.getNumberOfColumns
▸ getNumberOfRows(): number
Return number of rows
number
number of rows
AbstractDataTable.getNumberOfRows
▸ getValue(rowIndex, columnIndex): any
Return a cell value
| Name | Type | Description |
|---|---|---|
rowIndex | number | index of the row |
columnIndex | number | index of the column |
any
a cell value
▸ getViewColumns(): number[]
Returns the columns in this view. Identical array will be returned after calling setColumns().
number[]
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
AbstractDataTable.hasEventListener
▸ indexOfColumn(column): number
Return index of column
| Name | Type | Description |
|---|---|---|
column | AbstractDataSeries<any> | a column |
number
index of th column or -1 if column is not found
AbstractDataTable.indexOfColumn
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): DataTableView
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | DataTableView | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(type?, callback?): DataTableView
Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: DataTableView, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): DataTableView
Attach listener on event that will be called whenever the specified event is delivered to the target
If the callback function is already in the list of event listeners for this target, the function is not added a second time.
If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: DataTableView, args: EventMap[E]) => void | to be called |
this
▸ query(): QueryBuilder<any>
Query data item and child items by different conditions
Example
// Select by function
tableView.query()
.where( (item) => return item.getUri() === 'itemuri')
.select((item) => {
founditem = item;
});Example
// Select by expression
tableView.query()
.where('item => uri(item) == "itemuri"')
.select((item) => {
founditem = item;
});QueryBuilder<any>
query object which has methods 'where' to specify conditions, 'select' to run query, 'selectToArray' select results to array Expressions syntax: "item => expression", where expression:
- logical and arithmetic operators
- embedded functions: name(item) - gets name of the data object url(item) - gets url of the data object type(item) - gets type of the data object
▸ setColumns(columnIndexes): DataTableView
Sets visible columns indexes. Any columns not specified will be hidden.
| Name | Type | Description |
|---|---|---|
columnIndexes | number[] | array of column indexes |
▸ setName(name): DataTableView
Sets name of the table
| Name | Type | Description |
|---|---|---|
name | string | new table name |
▸ setSilent(bool): DataTableView
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ Static getClassName(): string
string