Views: Tables, Kanban, and Calendars
Relevant source files
The following files were used as context for generating this wiki page:
- packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts
- packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx
- packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx
- packages/twenty-front/src/modules/object-record/record-calendar/components/RecordCalendar.tsx
- packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/workflow-versions-all.view.ts
- README.md
Views are a core feature of Twenty, providing users with flexible and personalized ways to visualize CRM data. They allow records of an object to be displayed in different formats, such as a traditional table, a Kanban board, or a calendar. Each view can be customized with its own set of filters, sorting rules, and field visibility, enabling users to create tailored layouts for specific workflows and data analysis needs.
The system supports several view types, each rendered by a dedicated React component on the frontend. These views are defined by a ViewDefinition data structure on the backend, which specifies the view's type, associated object, display properties, and data-shaping rules like filters and sorts. This architecture allows for a consistent yet customizable user experience across different data objects.
Sources: README.md, packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/workflow-versions-all.view.ts:12-15
View Architecture
The view system is composed of backend definitions and frontend rendering components. A ViewDefinition entity stored in the database dictates how a specific view should behave, and the frontend selects the appropriate component to render the data accordingly.
This diagram illustrates the relationship between a backend View Definition and the frontend components that render it.
Sources: packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx, packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx, packages/twenty-front/src/modules/object-record/record-calendar/components/RecordCalendar.tsx, packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/workflow-versions-all.view.ts:34
View Definition
A view is defined by the ViewDefinition structure. This configuration object contains all the necessary metadata to render a view, including its type, name, associated data object, and presentation settings.
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier for the view. |
universalIdentifier | string | A stable, universal identifier for standard views. |
applicationId | string | The ID of the application this view belongs to. |
name | string | The display name of the view. |
objectMetadataId | string | The ID of the object whose records are being displayed. |
type | 'table' | 'board' | 'calendar' | The type of visualization to use. |
key | string | A key for the view, e.g., 'INDEX'. |
position | number | The display order of the view in the UI. |
icon | string | The name of the icon to display for the view. |
openRecordIn | ViewOpenRecordInType | Defines where a record should open when clicked (e.g., in a new page). |
filters | array | An array of filter conditions to apply to the data. |
fields | array | An array defining the fields to display, their position, size, and visibility. |
Below is an example of a ViewDefinition for a standard table view that displays workflow versions.
// packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/workflow-versions-all.view.ts
export const workflowVersionsAllView = ({...}): ViewDefinition => {
// ...
return {
id: v4(),
universalIdentifier: viewUniversalIdentifier,
applicationId: twentyStandardFlatApplication.id,
name: useCoreNaming
? msg`All {objectLabelPlural}`
: 'All Workflow Versions',
objectMetadataId: workflowVersionObjectMetadata.id,
type: 'table',
key: 'INDEX',
position: 0,
icon: 'IconVersions',
openRecordIn: ViewOpenRecordInType.RECORD_PAGE,
filters: [],
fields: [
{
fieldMetadataId: '...',
position: 0,
isVisible: true,
size: 210,
universalIdentifier: '...',
},
// ... other fields
],
};
};
View Types
Table View
The Table View, implemented in the RecordTable component, is the default and most common way to display a list of records. It presents data in a familiar grid format with rows and columns.
- Component:
RecordTable.tsx - Functionality:
- Displays records in a customizable grid.
- Columns correspond to the
fieldsconfigured in theViewDefinition. - Supports record selection, sorting, and inline editing (functionality implied by a standard table component).
Sources: packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx
Kanban (Board) View
The Kanban View, implemented in RecordBoard, is ideal for visualizing workflows and pipelines. It organizes records into columns based on the value of a specific field, typically a "Status" or "Stage" field.
- Component:
RecordBoard.tsx - Functionality:
- Groups records into columns based on a
groupByfield. - Supports drag-and-drop (
DndContext) to move records between columns, which updates the underlying record's data. - Each column represents a value of the grouped field (e.g., "To Do", "In Progress", "Done").
- Groups records into columns based on a
Sources: packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx
Calendar View
The Calendar View, implemented in RecordCalendar, displays records on a calendar based on their date or date-time fields. This is useful for tracking events, deadlines, and appointments.
- Component:
RecordCalendar.tsx - Functionality:
- Renders records as events on a calendar.
- The component receives
eventsderived from the records, which are then plotted on the calendar. - Suitable for time-sensitive data like meetings, tasks with due dates, or opportunities with close dates.
Sources: packages/twenty-front/src/modules/object-record/record-calendar/components/RecordCalendar.tsx
View Management
Creating a New View
Users can create a new view by duplicating an existing one. The useCreateViewFromCurrentView hook facilitates this process. It copies the configuration of the current view (including filters, sorts, and groups) to a new view, which the user can then further customize.
The following sequence diagram shows the flow for duplicating a view.
The hook uses the useCreateViewMutation GraphQL mutation. It constructs the new view's properties by taking most from the currentView and setting a new name.
// packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts
export const useCreateViewFromCurrentView = (currentView: View) => {
// ...
const [createViewMutation] = useCreateViewMutation();
const createView = async () => {
const { data } = await createViewMutation({
variables: {
view: {
objectMetadataId: currentView.objectMetadata.id,
name: t(msg`Copy of ${currentView.name}`),
type: currentView.type,
filters: currentView.filters,
sorts: currentView.sorts,
groups: currentView.groups,
fields: currentView.fields.map((field) => ({
// ...
})),
},
},
});
// ...
};
// ...
};
Sources: packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts:16-36
Summary
The Views system in Twenty is a powerful and flexible feature for data visualization. By separating view definitions on the backend from rendering logic on the frontend, it allows for multiple, customizable representations of the same underlying data. The support for Table, Kanban, and Calendar views covers a wide range of common CRM use cases, from simple data lists to complex pipeline and schedule management. The ability to easily duplicate and modify existing views further enhances user productivity by allowing them to quickly create tailored data layouts.