Skip to content

Columns

Every table in a base contains columns. The following calls are available to interact with the columns of a table.

Get Columns

listColumns

base.listColumns(table_name, (view_name = ""));

Example

const columns1 = await base.listColumns("Table1");
const columns2 = await base.listColumns("Table1", (view_name = "default"));

getColumnByName

base.getColumnByName(table_name, column_name);

Example

const col = await base.getColumnsByName('Table1', 'Name');

getColumnsByType

base.getColumnsByType(table_name, col_type);

Example

const cols = await base.getColumnsByType('Table1', 'number')

Add Column

insertColumn

base.insertColumn(table_name, column_name, column_type, column_key='', column_data='')

Example

import { ColumnTypes } from 'seatable-api';
await base.insertColumn('Table1', 'seatable-api', ColumnTypes.TEXT)
await base.insertColumn('Table1', 'seatable-api', ColumnTypes.TEXT, '0000')
await base.insertColumn('Table1', 'Link1', ColumnTypes.LINK, column_data={
        'table':'Table1',
        'other_table':'Test_User'
    })

Rename Column

renameColumn

base.renameColumn(table_name, column_key, new_column_name)

Example

await base.renameColumn('Table1', 'kSiR', 'new-seatable-api')

Column Settings

resizeColumn

base.resizeColumn(table_name, column_key, new_column_width)

Example

await base.resizeColumn('Table1', 'asFV', 500)

freezeColumn

base.freezeColumn(table_name, column_key, frozen)

Example

await base.freezeColumn('Table1', '0000', true)

moveColumn

base.moveColumn(table_name, column_key, target_column_key)

Example In this example, the 'loPx' column will be moved to the right of the '0000' column

await base.moveColumn('Table1', 'loPx', '0000')

modifyColumnType

base.modifyColumnType(table_name, column_key, new_column_type)

Example

import { ColumnTypes } from 'seatable-api';
await base.modifyColumnType('Table1', 'nePI', ColumnTypes.NUMBER)

addColumnOptions

Used by single-select or multiple-select type columns

base.addColumnOptions(table_name, column, options)

Example

await base.addColumnOptions('Table1', 'My choices', [
        {"name": "ddd", "color": "#aaa", "textColor": "#000000"},
        {"name": "eee", "color": "#aaa", "textColor": "#000000"},
        {"name": "fff", "color": "#aaa", "textColor": "#000000"},
])

addColumnCascadeSettings

Used by single-select column, to add a limitation of child column options according to the option of parent column

base.addColumnCascadeSettings(table_name, child_column, parent_column, cascade_settings)

Example

await base.addColumnCascadeSettings("Table1", "single-op-col-c", "single-op-col", {
"aaa": ["aaa-1", "aaa-2"], # If aaa is selected by parent column, the available options of child column are "aaa-1 and aaa-2"
"bbb": ["bbb-1", "bbb-2"],
"ccc": ["ccc-1", "ccc-2"]
})

Delete Column

deleteColumn

base.deleteColumn(table_name, column_key)

Example

await base.deleteColumn('Table1', 'bsKL')