Table

Updated at:

Introduction

The table component is a low-code tool for displaying and managing large amounts of structured data. It includes built-in features such as sorting, filtering, searching, and paging. Developers can use simple configurations and drag-and-drop actions to quickly build rich data display interfaces. The component is highly customizable and can be used in various scenarios, from basic data lists to complex interactive systems. It offers an intuitive and efficient data management experience.

As shown in the following figure, the table component consists of three main parts: a toolbar, a table area, and a paging area. The table area contains two basic units: data columns and operation columns.

Configuration items

Category

Configuration

Example

Description

Content

Data source

image

The data source for the table. Use this to configure the structured data source that the table currently displays. As the example shows, this configuration item must be a standard array of JavaScript objects.

Primary key

The field name that uniquely identifies each row in the structured data. In the table component, it acts as the unique identifier for each record to ensure accurate data referencing and operations.

Important

The primary key must be unique and stable across the entire structured dataset.

A correct primary key ensures that the table data renders properly and that the currentItem is retrieved accurately.

Empty data text

image

The text to display in the table area when the data source is empty.

Data column configuration

image

image

Configures the display and behavior of each column in the table. The main configuration items are as follows:

  • Title: The content of the data column header.

  • Tooltip: The tooltip text for the data column header. When you enter text, a question mark icon appears to the right of the header title. Hover over the icon to display the tooltip.

  • Fit to width: Specifies whether the column width automatically adjusts.

  • Width: When Fit to width is turned off, this sets the column width in pixels.

  • Truncate when overflowing: Specifies whether to truncate overflowing cell content with an ellipsis.

  • Hidden: Specifies whether to hide the column.

  • Fixed: Specifies whether to fix the column to the left or right side of the table area.

  • Content alignment: Sets the content alignment for the entire column. Options are Left, Center, or Right.

  • Column type: Defines how cell content is displayed in the data column. The data constraints and detailed configurations for each type are as follows:

    • Text: The property constraint for a text column is the string type. Cell data is displayed as text. The specific configuration for a text column is as follows:

      • Text color: The text color of the cell content.

    • Markdown: The property constraint for a Markdown column is the string type. The cell data supports Markdown text rendering and display.

    • Number: The property constraint for a number column is the number type. The cell data is displayed as a number.

    • Date: The property constraint for a date column is the number or string type. The number type supports standard UNIX timestamps. The string type supports date strings in a specified format or ISO 8601 time strings. The cell displays the date and time in the specified format. The specific configuration for a date column is as follows:

      • Format: The format description for the time content in the cell, such as YYYY-MM-DD.

    • Rating: The property constraint for a rating column is the number type. The cell data is displayed as a rating component.

    • Link: The property constraint for a link column is the string type. The cell data is displayed as a text link. The specific configuration for a link column is as follows:

      • Event: Defines the event handler to trigger when the link is clicked.

    • Image: The property constraint for an image column is the string type. The string type supports an image URL string. The cell renders the image from the URL.

    • Progress bar: The property constraint for a progress bar column is the number type. The cell data is displayed as a progress bar component. The specific configurations for a progress bar column are as follows:

      • Content text type: The type of text that is displayed in the progress bar. For more information, see the Progress bar component document.

      • Custom content: The custom content to display when the progress bar type is set to Custom. For more information, see the Progress bar widget documentation.

      • Default progress bar color: The default color of the progress bar. For more information, see the Progress Bar component documentation.

    • Status: The property constraint for a status column is the string type. The cell data is displayed as a combination of text and a status dot. The specific configuration for a status column is as follows:

      • Status: The display style of the small dot in the status column. When the value is an expression, this content supports enumerated strings with values such as success, processing, default, error, or warning.

    • Profile picture: The property constraint for a profile picture column is the string type. The string type supports descriptive text or an image URL string. The cell renders the content as text or an image from the URL based on the configuration. The specific configurations for a profile picture column are as follows:

      • Type: The display type of the profile picture component. For more information, see the Profile Picture component documentation.

      • Text color: Takes effect when the profile picture type is text. Configures the color of the text content.

      • Background color: Takes effect when the profile picture type is text. Configures the background color of the text-based profile picture.

    • Tag: The property constraint for a tag column is the string type. The cell is rendered as a tag component. The specific configuration for a tag column is as follows:

      • Color: Sets the theme color of the tag component. For more information, see the Tag component documentation.

    • Tag group: The property constraint for a tag group column is a string array type. The cell is rendered as multiple tag components. The specific configuration for a tag column is as follows:

      • Color: Sets the theme color for each tag component in the tag group. For more information, see the Tag component documentation.

    • Button: The property constraint for a button column is the string type. The cell is rendered as a button component with the string as its content. The specific configurations for a button column are as follows:

      • Button type: For more information, see the Button component documentation.

      • Button width: The width of the button in pixels.

      • Button line height: The line height of the button.

      • Style properties: For details about the configuration items, see the Button component documentation.

    • Switch: The property constraint for a switch column is the Boolean type. The cell data is displayed as a switch component.

  • Field mapping: The path to the column data within the data item. The data column uses this path to get data for cell rendering.

  • Dynamic mapping: Specifies whether to enable dynamic mapping. When enabled, the cell no longer uses the data from the field mapping for rendering.

  • Mapping rule: Takes effect when dynamic mapping is enabled. You can write custom interpolation expressions to determine the cell's rendered content. The expression statement can use the iterator variable currentItem to get the current row's data. For example, {{ currentItem.name + ' student' }} sets the cell to display the name from the row data and appends the suffix ' student'.

    Important

    currentItem depends on the correct configuration of the primary key.

  • Editable: Specifies whether to enable cell editing. This feature currently works only for text, date, and number columns.

  • Enable filtering: Specifies whether to enable the data column filtering feature.

  • Filter settings: The specific filter settings are as follows:

    • Filter options: Set the title and value for preset filter options.

  • Enable sorting: Specifies whether to enable the data column sorting feature.

  • Sort settings: The specific sort settings are as follows:

Operation column configuration

image

image

Configures the content and interactive behavior of the operation column on the right side of the table area. The main configuration items are as follows:

  • Title: The header title for the operation column.

  • Fit to width: Specifies whether the operation column width automatically adjusts.

  • Style: The display style for items in the operation column. Options are Link or Button.

  • Operation column: Defines the specific content and interaction for operation items. If no operation items are configured, the table does not display the operation column. The main configurations are as follows:

    • Title: The display content of the operation item.

    • Hidden: Specifies whether to hide the operation item.

    • Tooltip: The content to display when you hover over the operation item.

    • Disabled: Specifies whether to disable the operation item.

    • Position: The position of the operation item. Options are Outside, Collapsed, or Both. If you select Collapsed or Both, the item is placed in a 'More' dropdown menu on the right side of the row.

    • Event: Defines the event handler to trigger when the operation item is clicked.

Show toolbar

image

Specifies whether to show the table toolbar.

Toolbar configuration

image

image

Configures the title, style, and interaction of the settings items in the table component's toolbar. The main configuration items are as follows:

  • Title: The toolbar title.

  • Title font size: The font size of the toolbar title.

  • Title font weight: The font weight of the toolbar title.

  • Title color: The color of the toolbar title.

  • Settings area: The style and interaction for each settings item in the settings area on the right side of the toolbar. The specific configurations are as follows:

    • Tooltip: The text content to display when you hover over this configuration item.

    • Type: The interaction type for this configuration item. Options are Column settings or Custom. If you select Column settings, a column filter pop-up appears when this item is clicked.

    • Icon: The icon style for this configuration item.

    • Event: The event handler to trigger when this configuration item is clicked.

Interaction

Hidden

image

Hidden. For more information, see Common Properties.

Keep layout when hidden

image

Preserves the layout when hidden. For details, see Common Properties.

Loading

image

Specifies whether the table component shows a loading state.

Row selection mode

image

Defines the interaction mode for selecting table rows.

Paging settings

image

Defines the display and interaction of the paging area. The main configurations are as follows:

  • Enable paging: Specifies whether to display the pager.

  • Size: The size of the pager.

  • Page size: The number of data items per page.

  • Position: The position of the pager relative to the component.

  • Hide on single page: Specifies whether to hide the pager when there is only one page of data.

  • Quick jump: Specifies whether to show the quick jump interaction area.

  • Show size changer: Specifies whether to show the page size changer.

  • Server-side paging: Specifies whether to enable controlled data paging.

  • Controlled page number: Takes effect when server-side paging is enabled. Receives the controlled current page number.

  • Controlled total count: Takes effect when server-side paging is enabled. Receives the controlled total number of data items.

Style

Margin

image

Outer margin. For more information, see General Properties.

Table size

image

The size of the table.

Show column borders

image

Specifies whether to show column borders.

Table background color

image

Defines the background color of the table.

Header background color

image

Defines the background color of the table header.

Header text color

image

Defines the text color of the table header.

Header separator color

image

Defines the color of the separator lines in the table header.

Table border color

image

Defines the border color of the table.

Properties and methods

Name

Type

Example

Description

dataSource

Array<any>

table1.dataSource

The data source of the table component.

column

Array<{

title: string;

hidden: boolean;

dataIndex: string;

type: string;

}>

table1.column

The column configuration data of the table component.

rowKey

string

table1.rowKey

The primary key of the table component.

changedArray

Array<any>

table1.changedArray

The data that has changed after saving edits to the table.

selectedRows

Array<any>

table1.selectedRows

The currently selected data content in the table.

pagination

{

current: number;

pageSize: number;

}

table1.pagination

The paging data for the table, which includes the current page number and page size.

currentSort

Array<{

key: string;

order?: 'ascend' | 'descend'

}>

table1.currentSort

Data about the current sorting state of the table.

currentFilter

Array<{

key: string;

value?: any[];

}>

table1.currentFilter

Data about the current filtering state of the table.

rowSelectionMode

multiple | single | none

table1.rowSelectionMode

The current row selection mode of the table.

loading

boolean

table1.loading

The current loading state of the table component.

setDataSource

func

table1.setDataSource(xxxx)

Sets the data source for the table.

clearDataSource

func

table1.clearDataSource()

Clears the data source of the table.

setLoading

func

table1.setLoading(true)

Sets the loading state of the table.

clearLoading

func

table1.clearLoading()

Clears the loading state of the table.

setColumns

func

table1.setColumns(xxx)

Sets the column configuration for the table. Use this method to dynamically show operation columns or change column configurations.

setSelections

func

table1.setSelections(['id', 'id2'])

Sets the currently selected data rows in the table.

clearSelections

func

table1.clearSelections()

Clears the currently selected data rows in the table.

Event callbacks

Configuration

Description

image

The event triggered when the table is clicked.

image

The event triggered when a table row is selected.

image

The event triggered when editable table data is saved.

image

The event triggered when paging, filtering, or searching changes in the table.