Skip to content

Column

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

List columns

List columns

List all rows of the table/view.

base.list_columns(table_name, view_name=None);

Example

base.list_columns('Table1', default)

Get column by name

base.get_column_by_name(table_name, colume_name)

Example

base.get_column_by_name('Table1', 'Name')

Get columns by type

base.get_columns_by_type(table_name, column_type)

Example

from seatable_api.constants import ColumnTypes
base.get_columns_by_type('Table1', ColumnTypes.TEXT)

Insert column

Insert column

Insert or append a column to a table.

base.insert_column(table_name, column_name, column_type, column_key=None, column_data=None)

Examples

base.insert_column('Table1', 'New long text column', 'long text')
from seatable_api.constants import ColumnTypes
base.insert_column('Table1', 'Link', ColumnTypes.LINK, column_data={
    'table':'Table1',
    'other_table':'Test_User'
})

Rename column

Rename column

Rename a column.

base.rename_column(table_name, column_key, new_column_name)

Example

base.rename_column('Table1', 'kSiR', 'new column name')

Freeze column

Freeze column

Freeze a column.

base.freeze_column(table_name, column_key, frozen)

Example

base.freeze_column('Table1', '0000', True)

Move column

Move column

Move column. In this example, the column with the key loPx will be moved to the right of the column 0000.

base.move_column(table_name, column_key, target_column_key)

Example

base.move_column('Table1', 'loPx', '0000')

Modify column types

Modify column type

Change the column type of an existing column

base.modify_column_type(table_name, column_key, new_column_type)

Example

base.modify_column_type('Table1', 'nePI', 'checkbox')

Add column options

Add column options

Used by single-select or multiple-select type columns to add new options.

add_column_options(self, table_name, column, options)

Example

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

Add column cascade settings

Add column cascade settings

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

add_column_cascade_settings(table_name, child_column, parent_column, cascade_settings)

Example

base.add_column_cascade_settings("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

Delete column

Deletes a column from the table.

base.delete_column(table_name, column_key)

Example

base.delete_column('Table1', 'bsKL')