Skip to content

Views

Global structure

Here is the global structure of a view object:

{
    "_id": "0000",
    "name": "Default View",
    "type": "table",
    "is_locked": false,
    "rows": [],
    "formula_rows": {},
    "summaries": [],
    "filter_conjunction": "And",
    "sorts": [],
    "filters": [],
    "hidden_columns": [],
    "groupbys": [],
    "group_rows": [],
    "groups": []
}

Please refer to the SeaTable API Reference for a more detailed presentation.

Get View(s)

getActiveView

Get the current view of the active table. Only available in SeaTable scripts.

base.getActiveView();

Output Single view object

Example

const view = base.getActiveView();
output.text(view.name);

getViewByName

Get a view of a table, specified by its name.

base.getViewByName(table, viewName);

Output Single view object (undefined if no view with that name exists)

Example

const view = base.getViewByName('Table1', 'Default View');

listViews

Get all the views of a table.

base.listViews(table);

Output Array of view objects

Example

const views = base.listViews('Table1');

Add View

addView

Add a new view to a table.

base.addView(table, viewName);

Example

base.addView('Table1', 'My View');

Rename View

renameView

Rename an existing view.

base.renameView(table, currentViewName, newViewName);

Example

base.renameView('Table1', 'Default View', 'Main View');

Delete View

deleteView

Delete a view. Deleting the last view is not possible.

base.deleteView(table, viewName);

Example

base.deleteView('Table1', 'Old View');