Skip to main content

Methods

Method properties that can be called directly on the Active Table element.

info

Make sure the Active Table component has been fully rendered on the DOM before using these.

getData

  • Type: () => (string|number)[][]

Returns current table contents 2D array.

Example

Method results:
>
tableElementRef.getData();

getColumnsDetails

Returns details related to existing columns - width, typeName and cellDropdownItems (if the column type contains a dropdown). This is particularly useful if the user has made changes to columns and you want to recreate them in the next session on the initial load.

Example

Method results:
>
tableElementRef.getColumnsDetails();

updateCell

  • Type: (update: CellDetails) => void

CellDetails

  • Type: {
         newText: string | number,
         rowIndex: number,
         columnIndex: number
    }

Update cell text programmatically. Both rowIndex and columnIndex start at 0 where it is the header row for rowIndex and the left-most column for columnIndex.

Example

tableElementRef.updateCell({newText: 'sample text', rowIndex: 1, columnIndex: 1});

updateStructure

StructureDetails

  • Type: {
         structure: "row" | "column",
         isInsert: boolean,
         index: number,
         data?: (string|number)[]
    }

Programmatically insert/remove rows/columns.
structure defines whether the structure type is for a "row" or a "column".
isInsert sets the update behaviour; true will create a new structure, false will remove an existing one.
index is the row/column index. When adding a new structure, a value of -1 will append it to the end of the table.
data defines the new cells' content. If not defined and the update is for an insert, this will be populated with defaultText.

Example

tableElementRef.updateStructure({
structure: 'row',
isInsert: true,
index: -1,
data: ['New Planet', '12345', '500', '10', '357'],
});

updateData

  • Type: (data: (number | string)[][]) => void

Programmatically reset table data using the new data iside the data argument.

Example

tableElementRef.updateData([
['Planet', 'Diameter', 'Mass', 'Moons', 'Density'],
['Mercury', 4879, 0.33, 0, 5429],
['Venus', 12104, 4.87, 0, 5243],
['Uranus', 51118, 86.8, 27, 1270],
['Pluto', 2376, 0.013, 5, 1850],
['Moon', 3475, 0.073, 0, 3340],
]);

importFile

Opens up a file browser window to select a file and import its data. You can optionally pass an options object to define the allowed file formats and what they will overwrite. For browser security reasons - this method can ONLY be activated through user actions, such as a click of a button.

Example

tableElementRef.importFile();
info

csv files are supported natively, however if you want to import any of the other file formats - you will need to add the xlsx module into your project. Please see examples here.

exportFile

ExportSingleFile

Exports existing table data into a file. You can optionally pass a ExportSingleFile object to define the exported file's name and its format.

Example

tableElementRef.exportFile();
info

csv files are supported natively, however if you want to export any of the other file formats - you will need to add the xlsx module into your project. Please see examples here.