DataGrid

Description

The DataGrid class represents the main class for the DataGrid. It exposes functions to specify how it looks and behaves. It can be configured by providing options at construction, or dynamically by calling its different functions at runtime.

Get Functions

Function Name

Parameter

Type

Return type

Description

getOptions

 

 

DataGridOptions

Returns the DataGridOptions currently set on the DataGrid.

getColumnDefinitions

 

 

ColumnDefinition[]

Returns an array of ColumnDefinition currently present in the DataGrid.

getColumnDefinitionById

id

string

ColumnDefinition | undefined

Returns a ColumnDefinition object whose id property matches the id parameter value, or undefined if no match is found.

getColumnDefinitionsById

ids

string[]

ColumnDefinition[]

Returns an array of ColumnDefinition for each id property that matches one of the ids provided in the parameter array.

getDataSource

 

 

DataProvider | undefined

Returns the DataProvider currently used by the DataGrid.

getFilterDefinitions

 

 

FilterDefinitionCollection

Returns a collection of key/value pairs representing the FilterDefinition currently applied in the DataGrid.

getGroupDefinitions

 

 

GroupDefinition[]

Returns an array of GroupDefinition currently applied in the DataGrid.

getSelectedItems

   

Promise<RawItem[]>

Returns an array of RawItem representing the selected items from the DataGrid.

getSelectedCellRanges

   

Promise<SelectedCellRange[]>

Returns an array of SelectedCellRange representing the selected data cells from the DataGrid.

getSortDefinitions

 

 

SortDefinition[]

Returns an array of SortDefinitions currently applied in the DataGrid.

getValidationErrors

 

 

ValidationErrors[]

Returns an array of ValidationErrors currently present in the DataGrid.

Set Functions

Function Name

Parameter

Type

Description

constructor

container, options?

HTMLElementRef, PartialDataGridStartupOptions

Container is the root html element which serves as the parent element containing the DataGrid; options determines how to configure the DataGrid.

setOptions

options

PartialDataGridOptions

An object containing options to apply to the DataGrid.

setColumnDefinitions

columnDefinitions

PartialColumnDefinition[]

An array of ColumnDefinition to display in the DataGrid.

addColumnDefinitions

columnDefinitions

PartialColumnDefinition[]

An array of ColumnDefinition to add in the DataGrid.

insertColumnDefinitions

index, columnDefinitions

number, PartialColumnDefinition[]

An array of ColumnDefinition to insert in the DataGrid at a given index.

upateColumnDefinitions

columnDefinitions

PartialColumnDefinition[]

An array of ColumnDefinition to update in the DataGrid.

removeColumnDefinitions

ids

string[]

An array of string identifying ColumnDefinition to remove from the DataGrid.

addEventListener

eventName, listener

T, EventHandler<T>

Adds a listener that fires whenever the event specified by eventName is raised in the DataGrid.

removeEventListener

eventName, listener

T, EventHandler<T>

Unsubscribes the listener from the event specified by eventName.

setDataSource

dataSource

DataSource

A DataSource representing the data to display in the DataGrid.

setFilterDefinitions

filterDefinitions

PartialFilterDefinitionCollection

A collection of key/value pairs representing the FilterDefinition to apply filtering on the data of the DataGrid.

setGroupDefinitions

groupDefinitions

PartialGroupDefinition[]

An array of GroupDefinition to apply grouping on the data of the DataGrid.

setSortDefinitions

sortDefinitions

PartialSortDefinition[]

An array of SortDefinition to apply sorting on the data of the DataGrid

 

Example

let columnDefinitionToUpdate = datagrid.getColumnDefinitionById("weight");

columnDefinitionToUpdate.title = "Weight (kg)"

datagrid.updateColumnDefinitions([columnDefinitionToUpdate]);

In this example, the column with id “weight” is retrieved, and its title property updated, and given back to the DataGrid.