Last updated

API / geotoolkit / data / DataTableView / DataTableView

Class: 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

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new DataTableView(dataTable)

new DataTableView(dataTable)

Parameters

Name Type
dataTableAbstractDataTable

Overrides

AbstractDataTable.constructor

Methods

dispose

dispose(): void

Dispose data table view object.

Returns

void

Overrides

AbstractDataTable.dispose


getClassName

getClassName(): string

Returns

string

Inherited from

AbstractDataTable.getClassName


getColumn

getColumn(columnIndex): DataSeriesView<any>

Return column by index

Parameters

Name Type Description
columnIndexnumberindex of the column

Returns

DataSeriesView<any>

a column

Overrides

AbstractDataTable.getColumn


getColumnById

getColumnById(id): AbstractDataSeries<any>

Return column by column id

Parameters

Name Type Description
idstring | numbercolumn id

Returns

AbstractDataSeries<any>

a column of null if column is not found

Overrides

AbstractDataTable.getColumnById


getColumnByName

getColumnByName(name): AbstractDataSeries<any>

Return column by name

Parameters

Name Type Description
namestringnam eof the column

Returns

AbstractDataSeries<any>

the first column with specified name or null if column is not found

Overrides

AbstractDataTable.getColumnByName


getColumnProperties

getColumnProperties(columnIndex): Record<string, any>

Returns the map of all properties of specified column.

Parameters

Name Type Description
columnIndexnumberindex of the column

Returns

Record<string, any>

Inherited from

AbstractDataTable.getColumnProperties


getDataTable

getDataTable(): AbstractDataTable

Get parent data table, which is used to create the current view

Returns

AbstractDataTable

data table


getMetaData

getMetaData(): Record<string, any>

Returns the map of all meta data of the data table. This method returns the reference to the meta data.

Returns

Record<string, any>

meta data

Overrides

AbstractDataTable.getMetaData


getName

getName(): string

Returns table name

Returns

string

Inherited from

AbstractDataTable.getName


getNumberOfColumns

getNumberOfColumns(): number

Returns number of columns in the view

Returns

number

number of columns in the view

Overrides

AbstractDataTable.getNumberOfColumns


getNumberOfRows

getNumberOfRows(): number

Return number of rows

Returns

number

number of rows

Overrides

AbstractDataTable.getNumberOfRows


getValue

getValue(rowIndex, columnIndex): any

Return a cell value

Parameters

Name Type Description
rowIndexnumberindex of the row
columnIndexnumberindex of the column

Returns

any

a cell value

Overrides

AbstractDataTable.getValue


getViewColumns

getViewColumns(): number[]

Returns the columns in this view. Identical array will be returned after calling setColumns().

Returns

number[]


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

AbstractDataTable.hasEventListener


indexOfColumn

indexOfColumn(column): number

Return index of column

Parameters

Name Type Description
columnAbstractDataSeries<any>a column

Returns

number

index of th column or -1 if column is not found

Overrides

AbstractDataTable.indexOfColumn


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

AbstractDataTable.isDisposed


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

AbstractDataTable.isSilent


notify

notify<E>(type, source, args?): DataTableView

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceDataTableViewof the event
Optional argsEventMap[E]arguments of the event

Returns

DataTableView

this

Overrides

AbstractDataTable.notify


off

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.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: DataTableView, args: EventMap[E]) => voidfunction to be called

Returns

DataTableView

this

Overrides

AbstractDataTable.off


on

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.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: DataTableView, args: EventMap[E]) => voidto be called

Returns

DataTableView

this

Overrides

AbstractDataTable.on


query

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;
});

Returns

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

setColumns(columnIndexes): DataTableView

Sets visible columns indexes. Any columns not specified will be hidden.

Parameters

Name Type Description
columnIndexesnumber[]array of column indexes

Returns

DataTableView


setName

setName(name): DataTableView

Sets name of the table

Parameters

Name Type Description
namestringnew table name

Returns

DataTableView

Inherited from

AbstractDataTable.setName


setSilent

setSilent(bool): DataTableView

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

DataTableView

this

Inherited from

AbstractDataTable.setSilent


getClassName

Static getClassName(): string

Returns

string

Inherited from

AbstractDataTable.getClassName