Flutter docs
Default skin

Table

A table displays rows of data.

When to use

  • To display a collection of structured data.
  • To sort, search, paginate, filter data.

Examples

Basic Usage

Simple table with actions.

JSX style API

Using JSX style API (introduced in 2.5.0) > Since this is just a syntax sugar for the prop columns, you can't compose Column and ColumnGroup with other Components.

selection

Rows can be selectable by making first column as a selectable column. You can use rowSelection.type to set selection type. Default is checkbox. > selection happens when clicking checkbox by default. You can see <https://codesandbox.io/s/000vqw38rl> if you need row-click selection behavior.

Selection and operation

To perform operations and clear selections after selecting some rows, use rowSelection.selectedRowKeys to control selected rows.

Custom selection

Use rowSelection.selections custom selections, default no select dropdown, show default selections via setting to true.

Filter and sorter

Use filters to generate filter menu in columns, onFilter to determine filtered result, and filterMultiple to indicate whether it's multiple or single selection, filterOnClose to specify whether to trigger filter when the filter menu closes. Use defaultFilteredValue to make a column filtered by default. Use sorter to make a column sortable. sorter can be a function of the type sorter: function(rowA, rowB) { ... } for sorting data locally. sortDirections: ['ascend', 'descend'] defines available sort methods for each columns, effective for all columns when set on table props. You can set as ['ascend', 'descend', 'ascend'] to prevent sorter back to default status. Use defaultSortOrder to make a column sorted by default. If a sortOrder or defaultSortOrder is specified with the value ascend or descend, you can access this value from within the function passed to the sorter as explained above. Such a function can take the form: function(a, b, sortOrder) { ... }.

Filter in Tree

You can use filterMode to change default filter interface, options: menu(default) and tree. > filterSearch is used for making filter dropdown items searchable.

Filter search

filterSearch is used to enable search of filter items, and you can set a custom filter method through filterSearch:(input, record) => boolean.

Multiple sorter

column.sorter support multiple to config the priority of sort columns. Though sorter.compare to customize compare function. You can also leave it empty to use the interactive only.

Reset filters and sorters

Control filters and sorters by filteredValue and sortOrder. > 1. Defining filteredValue or sortOrder means that it is in the controlled mode. > 2. Make sure sortOrder is assigned for only one column. > 3. column.key is required.

Customized filter panel

Implement a customized column search example via filterDropdown. Add the boolean type parameter closeDropdown to the function clearFilters. Whether to close the filter menu is true by default. Add the boolean type parameter confirm to clear whether to submit the option during filtering. The default is true.

Ajax

This example shows how to fetch and present data from a remote server, and how to implement filtering and sorting in server side by sending related parameters to server. Setting rowSelection.preserveSelectedRowKeys to keep the key when enable selection. **Note, this example use Mock API that you can look up in Network Console.**

size

There are two compacted table sizes: medium and small. The small size is used in Modals only.

border, title and footer

Add border, title and footer for table.

Expandable Row

When there's too much information to show and the table can't display all at once.

Order Specific Column

You can control the order of the expand and select columns by using Table.EXPAND_COLUMN and Table.SELECTION_COLUMN.

colSpan and rowSpan

Table column title supports colSpan that set in column. Table cell supports colSpan and rowSpan that set in onCell return object. When each of them is set to 0, the cell will not be rendered.

Tree data

Display tree structure data in Table when there is field key children in dataSource, try to customize childrenColumnName property to avoid tree table structure. You can control the indent width by setting indentSize.

Fixed Header

Display large amounts of data in scrollable view. > Specify width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no long word to break table layout.

Auto height

Wrap Table to make it always fill the container height automatically.

Fixed Columns

To fix some columns and scroll inside other columns, and you must set scroll.x meanwhile. > Specify the width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no long word to break table layout. > > A fixed value which is greater than table width for scroll.x is recommended. The sum of unfixed columns should not greater than scroll.x. **Note: v4 using sticky to implement fixed effect. IE 11 will downgrade to horizontal scroll.**

Stack Fixed Columns

Fixed column only when scroll some distance, and scroll to stack other columns. Recommend use with bordered.

Fixed Columns and Header

A Solution for displaying large amounts of data with long columns. > Specify the width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no long word to break table layout. > > A fixed value which is greater than table width for scroll.x is recommended. The sum of unfixed columns should not greater than scroll.x.

Hidden Columns

Hide columns with hidden.

Grouping table head

Group table head with columns[n].children.

Editable Cells

Table with editable cells. When work with shouldCellUpdate, please take care of closure.

Editable Rows

Table with editable rows.

Nested tables

Showing more detailed info of every row.

Drag sorting

By using components, we can integrate table with dnd-kit to implement drag sorting function.

Drag Column sorting

By using components, we can integrate table with dnd-kit to implement column drag sorting function.

Drag sorting with handler

Alternatively you can implement drag sorting with handler using dnd-kit.

ellipsis column

Ellipsis cell content via setting column.ellipsis. > Cannot ellipsis table header with sorters and filters for now.

Shared column props

Use column to set shared column props on the table and override them per column when needed.

ellipsis column custom tooltip

Ellipsis cell content via setting column.ellipsis.showTitle, use Tooltip instead of the html title attribute.

Custom empty

Custom empty status.

Summary

Set summary content by summary prop. Sync column fixed status with Table.Summary.Cell. You can fixed it by set Table.Summary fixed prop(since 4.16.0).

Virtual list

Set virtual to enable virtual scroll, and scroll.x and scroll.y must be set at the same time with number type.

Responsive

Responsive columns.

Pagination Settings

Table pagination settings.

Fixed header and scroll bar with the page

For long table,need to scroll to view the header and scroll bar,then you can now set the fixed header and scroll bar to follow the page.

Dynamic Settings

Select different settings to see the result.

Custom semantic dom styling

You can customize the semantic dom style of Table by passing objects/functions through classNames and styles.

API

Table, Table.Column, Table.ColumnGroup, and Table.Summary are exported from @ceebee/ui/client.

Table

PropertyDescriptionTypeDefaultVersion
borderedWhether to show all table bordersbooleanfalse—
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-—
columnShared props applied to columns when the same property is not defined on the column itselfPartial<ColumnType>-6.4.0
columnsColumns of tableColumnsType\[]-—
componentsOverride default table elementsTableComponents-—
dataSourceData record array to be displayedobject\[]-—
expandableConfig expandable contentexpandable-—
footerTable footer rendererfunction(currentPageData)-—
getPopupContainerThe render container of dropdowns in table(triggerNode) => HTMLElement() => TableHtmlElement—
loadingLoading status of tableboolean | Spin Propsfalse—
localeThe i18n text including filter, sort, empty text, etcobjectDefault Value—
paginationConfig of pagination. You can ref table pagination config or full pagination document, hide it by setting it to falseobject | false-—
rowClassNameRow's classNamefunction(record, index): string-—
rowKeyRow's unique key, could be a string or function that returns a stringstring | function(record): stringkey—
rowSelectionRow selection configobject-—
rowHoverableRow hoverbooleantrue5.16.0
scrollWhether the table can be scrollable, configobject-—
showHeaderWhether to show table headerbooleantrue—
showSorterTooltipThe header show next sorter direction tooltip. It will be set as the property of Tooltip if its type is objectboolean | Tooltip props & {target?: 'full-header' | 'sorter-icon' }{ target: 'full-header' }5.16.0
sizeSize of tablelarge | medium | smalllarge—
sortDirectionsSupported sort way, could be ascend, descendArray\[ascend, descend]—
stickySet sticky header and scroll barboolean | {offsetHeader?: number, offsetScroll?: number, getContainer?: () => HTMLElement}-4.6.0 (getContainer: 4.7.0)
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-—
summarySummary content(currentData) => ReactNode-—
tableLayoutThe table-layout attribute of table element- | auto | fixed-<hr />fixed when header/columns are fixed, or using column.ellipsis—
titleTable title rendererfunction(currentPageData)-—
virtualSupport virtual listboolean-5.9.0
onChangeCallback executed when pagination, filters or sorter is changedfunction(pagination, filters, sorter, extra: { currentDataSource: \[], action: paginate | sort | filter })-—
onHeaderRowSet props on per header rowfunction(columns, index)-—
onRowSet props on per rowfunction(record, index)-—
onScrollTriggered when the table body is scrolled. Note that only vertical scrolling will trigger the event when virtualfunction(event)-5.16.0

Table ref

PropertyDescriptionTypeDefaultVersion
nativeElementThe wrap elementHTMLDivElement5.11.0—
scrollToTrigger to scroll to target position. key match with record rowKey. When offset is specified, the table will scroll to align the target row to the top with the given offset and not working with top. Optional align param to control alignment: start align to top, center align to center, end align to bottom, nearest smart align (default). center align is not supported in virtual scrolling mode(config: { index?: number, key?: React.Key, top?: number, offset?: number, align?: 'start' | 'center' | 'end' | 'nearest' }) => void5.11.0—

Column

PropertyDescriptionTypeDefaultVersion
alignThe specify which way that column is alignedleft | right | centerleft—
classNameThe className of this columnstring-—
colSpanSpan of this column's titlenumber-—
dataIndexDisplay field of the data record, support nest path by string arraystring | string\[]-—
defaultFilteredValueDefault filtered valuesstring\[]-—
filterResetToDefaultFilteredValueclick the reset button, whether to restore the default filterbooleanfalse—
defaultSortOrderDefault order of sorted valuesascend | descend-—
ellipsisThe ellipsis cell content, not working with sorter and filters for now.<br />tableLayout would be fixed when ellipsis is true or { showTitle?: boolean }boolean | {showTitle?: boolean }falseshowTitle: 4.3.0
filterDropdownCustomized filter overlayReactNode | (props: FilterDropdownProps) => ReactNode-—
filteredWhether the dataSource is filteredbooleanfalse—
filteredValueControlled filtered value, filter icon will highlightstring\[]-—
filterIconCustomized filter iconReactNode | (filtered: boolean) => ReactNode-—
filterOnCloseWhether to trigger filter when the filter menu closesbooleantrue5.15.0
filterMultipleWhether multiple filters can be selectedbooleantrue—
filterModeTo specify the filter interface'menu' | 'tree''menu'4.17.0
filterSearchWhether to be searchable for filter menuboolean | function(input, record):booleanfalseboolean:4.17.0 function:4.19.0
filtersFilter menu configobject\[]-—
filterDropdownPropsCustomized dropdown props, filterDropdownOpen and onFilterDropdownOpenChange were available before <5.22.0DropdownProps-5.22.0
fixed(IE not support) Set column to be fixed: true(same as 'start') 'start' 'end'boolean | stringfalse—
keyUnique key of this column, you can ignore this prop if you've set a unique dataIndexstring-—
renderRenderer of the table cell. value is the value of current cell; record is the value object of current row; index is the row number. The return value should be a ReactNode(value: V, record: T, index: number): ReactNode-—
responsiveThe list of breakpoints at which to display this column. Always visible if not setBreakpoint\[]-4.2.0
rowScopeSet scope attribute for all cells in this columnrow | rowgroup-5.1.0
shouldCellUpdateControl cell render logic(record, prevRecord) => boolean-4.3.0
showSorterTooltipIf header show next sorter direction tooltip, override showSorterTooltip in tableboolean | Tooltip props & {target?: 'full-header' | 'sorter-icon' }{ target: 'full-header' }5.16.0
sortDirectionsSupported sort way, override sortDirections in Table, could be ascend, descendArray\[ascend, descend]—
sorterSort function for local sort, see Array.sort's compareFunction. If it is server-side sorting, set to true, but if you want to support multi-column sorting, you can set it to { multiple: number }function | boolean | { compare: function, multiple: number }-—
sortOrderOrder of sorted values: ascend descend nullascend | descend | null-—
sortIconCustomized sort icon(props: { sortOrder }) => ReactNode-5.6.0
titleTitle of this columnReactNode | ({ sortColumns, filters }) => ReactNode-—
widthWidth of this column (width not working?)string | number-—
minWidthMin width of this column, only works when tableLayout="auto"number-5.21.0
hiddenHidden this columnbooleanfalse5.13.0
onCellSet props on per cellfunction(record, rowIndex)-—
onFilterFunction that determines if the row is displayed when filteredfunction(value, record) => boolean-—
onHeaderCellSet props on per header cellfunction(column)-—

ColumnGroup

PropertyDescriptionTypeDefaultVersion
titleTitle of the column groupReactNode-—

pagination

PropertyDescriptionTypeDefaultVersion
placementSpecify the placement of Pagination, could betopStart | topCenter | topEnd |bottomStart | bottomCenter | bottomEnd | noneArray\[bottomEnd]—
positionSpecify the position of Pagination, could betopLeft | topCenter | topRight |bottomLeft | bottomCenter | bottomRight | none, please use placement insteadArray\[bottomRight]—

expandable

PropertyDescriptionTypeDefaultVersion
childrenColumnNameThe column contains children to displaystringchildren—
columnTitleSet the title of the expand columnReactNode-4.23.0
columnWidthSet the width of the expand columnstring | number-—
defaultExpandAllRowsExpand all rows initiallybooleanfalse—
defaultExpandedRowKeysInitial expanded row keysstring\[]-—
expandedRowClassNameExpanded row's classNamestring | (record, index, indent) => string-string: 5.22.0
expandedRowKeysCurrent expanded row keysstring\[]-—
expandedRowRenderExpanded container render for each rowfunction(record, index, indent, expanded): ReactNode-—
expandIconCustomize row expand Icon. Ref examplefunction(props): ReactNode-—
expandRowByClickWhether to expand row by clicking anywhere in the whole rowbooleanfalse—
fixedWhether the expansion icon is fixed. Optional true left rightboolean | stringfalse4.16.0
forceRenderForce render expanded row content before expansion. In virtual mode, only rows currently mounted by the virtual list are force-rendered; off-screen rows may still be unmountedbooleanfalse6.6.0
indentSizeIndent size in pixels of tree datanumber15—
rowExpandableEnable row can be expandable(record) => boolean-—
showExpandColumnShow expand columnbooleantrue4.18.0
onExpandCallback executed when the row expand icon is clickedfunction(expanded, record)-—
onExpandedRowsChangeCallback executed when the expanded rows changefunction(expandedRows)-—
expandedRowOffsetDeprecated: Expand the number of offset columns of the row. After setting, it will force the columns in front of it to be fixed columns. Please use'Table. EXPAND_COLUMN 'instead and control the position through column ordernumber-5.26.0

rowSelection

PropertyDescriptionTypeDefaultVersion
alignSet the alignment of selection columnleft | right | centerleft5.25.0
checkStrictlyCheck table row precisely; parent row and children rows are not associatedbooleantrue4.4.0
columnTitleSet the title of the selection columnReactNode | (originalNode: ReactNode) => ReactNode-—
columnWidthSet the width of the selection columnstring | number32px—
fixedFixed selection column on the leftboolean-—
getCheckboxPropsGet Checkbox or Radio propsfunction(record)-—
getTitleCheckboxPropsGet title Checkbox propsfunction()-—
hideSelectAllHide the selectAll checkbox and custom selectionbooleanfalse4.3.0
preserveSelectedRowKeysKeep selection key even when it removed from dataSourceboolean-4.4.0
renderCellRenderer of the table cell. Same as render in column(checked: boolean, record: T, index: number, originNode: ReactNode): ReactNode-4.1.0
selectedRowKeysControlled selected row keysstring\[] | number\[]\[]—
defaultSelectedRowKeysDefault selected row keysstring\[] | number\[]\[]—
selectionsCustom selection config, only displays default selections when set to trueobject\[] | boolean-—
typecheckbox or radiocheckbox | radiocheckbox—
onCellSet props on per cell. Same as onCell in columnfunction(record, rowIndex)-5.5.0
onChangeCallback executed when selected rows changefunction(selectedRowKeys, selectedRows, info: { type })-info.type: 4.21.0
onSelectCallback executed when select/deselect one rowfunction(record, selected, selectedRows, nativeEvent)-—

scroll

PropertyDescriptionTypeDefaultVersion
scrollToFirstRowOnChangeWhether to scroll to the top of the table when paging, sorting, filtering changesboolean-—
xSet horizontal scrolling, can also be used to specify the width of the scroll area, could be number, percent value, true and 'max-content'string | number | true-—
ySet vertical scrolling, can also be used to specify the height of the scroll area, could be string or numberstring | number-—

selection

PropertyDescriptionTypeDefaultVersion
keyUnique key of this selectionstring-—
textDisplay text of this selectionReactNode-—
onSelectCallback executed when this selection is clickedfunction(changeableRowKeys)-—