Datatable

All the methods listed here are available on the datatable instance created using the DataTable constructor.

Example

const datatable = new DataTable(container, options);
datatable.refresh(data);

refresh

Refreshes the datatable with new data and column

refresh(data: Array, columns: Array): void

// Usage
datatable.refresh(data, columns);

setDimensions

Refreshes the datatable layout.

setDimensions(): void

// Usage
datatable.setDimensions();

appendRows

Append new rows to the datatable

appendRows(rows: Array): void

// Usage
datatable.appendRows(rows);

showToastMessage

Show a toast message at the bottom center of the datatable. You can hide the message by providing hideAfter value which is in seconds.

showToastMessage(message: String, hideAfter: Number): void

// Usage
datatable.showToastMessage('Hey', 2);

clearToastMessage

Clear any toast message in the datatable.

clearToastMessage(): void

// Usage
datatable.clearToastMessage();

getColumns

Get all the columns

getColumns(): Array

// Usage
datatable.getColumns();

getRows

Get all the rows

getRows(): Array

// Usage
datatable.getRows();

freeze

Show an overlay on the datatable which displays the freezeMessage value provided in options. You cannot interact with the datatable when it is frozen.

freeze(): void

// Usage
datatable.freeze();

unfreeze

Remove the freeze overlay.

unfreeze(): void

// Usage
datatable.unfreeze();

style.setStyle

Add style to cells, rows, columns.

style.setStyle(selector: String, cssRule: Object): void

// Usage
datatable.style.setStyle(`.dt-cell--col-1`, {backgroundColor: '#00ff00'});