|
|
|
---
|
|
|
|
category: Components
|
|
|
|
group: Data Display
|
|
|
|
title: Table
|
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/f-SbcX2Lx/Table.svg
|
|
|
|
---
|
|
|
|
|
|
|
|
A table displays rows of data.
|
|
|
|
|
|
|
|
## When To Use
|
|
|
|
|
|
|
|
- To display a collection of structured data.
|
|
|
|
- To sort, search, paginate, filter data.
|
|
|
|
|
|
|
|
## How To Use
|
|
|
|
|
|
|
|
Specify `dataSource` of Table as an array of data.
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
const dataSource = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
name: 'Mike',
|
|
|
|
age: 32,
|
|
|
|
address: '10 Downing Street',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
name: 'John',
|
|
|
|
age: 42,
|
|
|
|
address: '10 Downing Street',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age',
|
|
|
|
dataIndex: 'age',
|
|
|
|
key: 'age',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Address',
|
|
|
|
dataIndex: 'address',
|
|
|
|
key: 'address',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
<Table dataSource={dataSource} columns={columns} />;
|
|
|
|
```
|
|
|
|
|
|
|
|
## Promotion
|
|
|
|
|
|
|
|
- [Kitchen Sketch Plugin 💎](https://kitchen.alipay.com)
|
|
|
|
- [ProTable - Advanced Tables](https://procomponents.ant.design/en-US/components/table)
|
|
|
|
- [S2 - Analytical Tables](https://github.com/antvis/s2/)
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
<code src="./demo/basic.tsx">Basic Usage</code>
|
|
|
|
<code src="./demo/jsx.tsx">JSX style API</code>
|
|
|
|
<code src="./demo/row-selection.tsx">selection</code>
|
|
|
|
<code src="./demo/row-selection-and-operation.tsx">Selection and operation</code>
|
|
|
|
<code src="./demo/row-selection-custom.tsx">Custom selection</code>
|
|
|
|
<code src="./demo/head.tsx">Filter and sorter</code>
|
|
|
|
<code src="./demo/filter-in-tree.tsx">Filter in Tree</code>
|
|
|
|
<code src="./demo/filter-search.tsx">Filter search</code>
|
|
|
|
<code src="./demo/multiple-sorter.tsx">Multiple sorter</code>
|
|
|
|
<code src="./demo/reset-filter.tsx">Reset filters and sorters</code>
|
|
|
|
<code src="./demo/custom-filter-panel.tsx">Customized filter panel</code>
|
|
|
|
<code src="./demo/ajax.tsx">Ajax</code>
|
|
|
|
<code src="./demo/size.tsx">size</code>
|
|
|
|
<code src="./demo/narrow.tsx" debug>size</code>
|
|
|
|
<code src="./demo/bordered.tsx">border, title and footer</code>
|
|
|
|
<code src="./demo/expand.tsx">Expandable Row</code>
|
|
|
|
<code src="./demo/order-column.tsx">Order Specific Column</code>
|
|
|
|
<code src="./demo/colspan-rowspan.tsx">colSpan and rowSpan</code>
|
|
|
|
<code src="./demo/tree-data.tsx">Tree data</code>
|
|
|
|
<code src="./demo/tree-table-ellipsis.tsx" debug>Tree data ellipsis debug demo</code>
|
|
|
|
<code src="./demo/fixed-header.tsx">Fixed Header</code>
|
|
|
|
<code src="./demo/fixed-columns.tsx">Fixed Columns</code>
|
|
|
|
<code src="./demo/fixed-columns-header.tsx">Fixed Columns and Header</code>
|
|
|
|
<code src="./demo/grouping-columns.tsx">Grouping table head</code>
|
|
|
|
<code src="./demo/edit-cell.tsx">Editable Cells</code>
|
|
|
|
<code src="./demo/edit-row.tsx">Editable Rows</code>
|
|
|
|
<code src="./demo/nested-table.tsx">Nested tables</code>
|
|
|
|
<code src="./demo/drag-sorting.tsx">Drag sorting</code>
|
|
|
|
<code src="./demo/resizable-column.tsx" debug>Resizable column</code>
|
|
|
|
<code src="./demo/ellipsis.tsx">ellipsis column</code>
|
|
|
|
<code src="./demo/ellipsis-custom-tooltip.tsx">ellipsis column custom tooltip</code>
|
|
|
|
<code src="./demo/summary.tsx">Summary</code>
|
|
|
|
<code src="./demo/virtual-list.tsx">Virtual list</code>
|
|
|
|
<code src="./demo/responsive.tsx">Responsive</code>
|
|
|
|
<code src="./demo/nest-table-border-debug.tsx" debug>Nested Bordered Table Debug</code>
|
|
|
|
<code src="./demo/pagination.tsx">Pagination Settings</code>
|
|
|
|
<code src="./demo/row-selection-custom-debug.tsx" debug>Custom selection group</code>
|
|
|
|
<code src="./demo/sticky.tsx">Fixed header and scroll bar with the page</code>
|
|
|
|
<code src="./demo/dynamic-settings.tsx">Dynamic Settings</code>
|
|
|
|
|
|
|