Views
A view determines how a table is presented to users. It can hide or reorder fields, filter, sort, and group records, and it holds the configuration that a view type requires to render as a grid, kanban board, calendar, gantt chart, or gallery.
View snapshot
| Property | Type | Description |
|---|---|---|
| id | string | View ID. |
| tableId | string | ID of the owning table. |
| name | string | View name. |
| type | BaseViewType | grid, kanban, calendar, gantt, gallery, pivot. |
| fieldOrder? | string[] | Field order in this view. |
| fieldSettings? | Record\<string, IViewFieldSetting\> | Visibility, width, and card settings per field. |
| filter? | `IFilterConfig | null` |
| sort? | ISortConfig[] | Sort rules. |
| group? | IGroupConfig[] | Group rules. |
| config | ViewSpecificConfig | Configuration specific to the view type. |
View types
| Type | Use case |
|---|---|
grid | Spreadsheet-style editing of a table. |
kanban | Cards grouped by a select, person, group, text, or date field. |
calendar | Records placed by date fields. |
gantt | Timeline planning with start and end date fields, planned-schedule comparison, completion, and predecessors. |
gallery | Card layout for records that are primarily visual or contain a large amount of content. |
pivot | Summaries and charts through the dashboard plugin. |
Gantt configuration uses startDateFieldId and endDateFieldId for the current schedule and progressFieldId for completion. IBaseGanttViewConfig extends the Gantt configuration with showPlanComparison, planStartDateFieldId, planEndDateFieldId, planColor, and remainingColor. Set dependencyFieldId to a multi-value Record Link field to track predecessors. workingDaysOnly and workingDays control the work calendar.
Create a view
TypeScript
const view = table.createView('Kanban', univerAPI.Enum.BaseViewType.Kanban)Configure filtering and sorting
TypeScript
view.setFilter({ conjunction: univerAPI.Enum.BaseFilterConjunction.AND, conditions: [ { fieldId: 'status', operator: univerAPI.Enum.BaseFilterOperator.IS, operand: 'In progress', }, ],})view.setSort([ { fieldId: 'dueDate', direction: univerAPI.Enum.BaseSortDirection.ASC },])Field visibility and width
TypeScript
view.setFieldVisible('internalNotes', false)view.setFieldWidth('title', 280)How is this guide?