Table表格
展示行列数据。
何时使用#
- 当有大量结构化的数据需要展现时;
- 当需要对数据进行排序、搜索、分页、自定义操作等复杂行为时。
import { NzTableModule } from 'ng-zorro-antd/table';
如何使用#
Table 组件同时具备了易用性和高度可定制性
高度定制#
在 nz-table
组件中完整的暴露了 W3C标准 <table>
的所有组成部分,你可以像使用 table
元素一样使用 nz-table
,根据依据业务需求,使用者可以自由的控制任何一个部分的样式、内容、逻辑和事件绑定。
组件增强#
在 nz-table
, thead
, th
, td
等多个暴露的元素上,组件提供了增强语法,经过配置之后可以很方便的实现多选、过滤、排序、固定列、固定表头、服务端分页等功能。
数据处理#
将数据传入[nzData]
,经过组件处理之后(包括分页、排序、筛选等),通过 模板变量 获取当前展示表格部分的数据,使用 *ngFor
依据需求将数据渲染。
<nz-table #basicTable [nzData]="dataSet">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td>{{data.name}}</td>
<td>{{data.age}}</td>
<td>{{data.address}}</td>
<td>
<a>Action 一 {{data.name}}</a>
<nz-divider nzType="vertical"></nz-divider>
<a>Delete</a>
</td>
</tr>
</tbody>
</nz-table>
代码演示
Name | Age | Address | Action |
---|---|---|---|
John Brown | 32 | New York No. 1 Lake Park | Action 一 John Brown |
Jim Green | 42 | London No. 1 Lake Park | Action 一 Jim Green |
Joe Black | 32 | Sidney No. 1 Lake Park | Action 一 Joe Black |
加载中
Selected 0 items
Name | Age | Address | |
---|---|---|---|
Edward King 0 | 32 | London, Park Lane no. 0 | |
Edward King 1 | 32 | London, Park Lane no. 1 | |
Edward King 2 | 32 | London, Park Lane no. 2 | |
Edward King 3 | 32 | London, Park Lane no. 3 | |
Edward King 4 | 32 | London, Park Lane no. 4 | |
Edward King 5 | 32 | London, Park Lane no. 5 | |
Edward King 6 | 32 | London, Park Lane no. 6 | |
Edward King 7 | 32 | London, Park Lane no. 7 | |
Edward King 8 | 32 | London, Park Lane no. 8 | |
Edward King 9 | 32 | London, Park Lane no. 9 |
加载中
Name | Age | Address | |
---|---|---|---|
Edward King 0 | 32 | London, Park Lane no. 0 | |
Edward King 1 | 32 | London, Park Lane no. 1 | |
Edward King 2 | 32 | London, Park Lane no. 2 | |
Edward King 3 | 32 | London, Park Lane no. 3 | |
Edward King 4 | 32 | London, Park Lane no. 4 | |
Edward King 5 | 32 | London, Park Lane no. 5 | |
Edward King 6 | 32 | London, Park Lane no. 6 | |
Edward King 7 | 32 | London, Park Lane no. 7 | |
Edward King 8 | 32 | London, Park Lane no. 8 | |
Edward King 9 | 32 | London, Park Lane no. 9 |
加载中
Jim Green | 42 | London No. 1 Lake Park |
Jim Red | 32 | London No. 2 Lake Park |
加载中
John Brown | 98 | 60 | 70 |
Jim Green | 98 | 66 | 89 |
Joe Black | 98 | 90 | 70 |
Jim Red | 88 | 99 | 89 |
加载中
John Brown | 32 | New York No. 1 Lake Park |
Jim Green | 42 | London No. 1 Lake Park |
Joe Black | 32 | Sidney No. 1 Lake Park |
Jim Red | 32 | London No. 2 Lake Park |
加载中
Age | Address | |
---|---|---|
John Brown | 32 | New York No. 1 Lake Park |
Jim Green | 42 | London No. 1 Lake Park |
Joe Black | 32 | Sidney No. 1 Lake Park |
Jim Red | 32 | London No. 2 Lake Park |
加载中
دینا رضایی | female | dyn.rdyy@example.com |
Kseniya Butko | female | kseniya.butko@example.com |
Christina Richards | female | christina.richards@example.com |
Brian Sims | male | brian.sims@example.com |
Joan Alonso | male | joan.alonso@example.com |
Manvitha Dsouza | female | manvitha.dsouza@example.com |
نیایش زارعی | female | nyysh.zraay@example.com |
Oliwia Bøhmer | female | oliwia.bohmer@example.com |
Clémentine Clement | female | clementine.clement@example.com |
Layla Wang | female | layla.wang@example.com |
加载中
加载中
加载中
Name | Age | Address | |
---|---|---|---|
John Brown | 32 | New York No. 1 Lake Park | |
My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park. | |||
Jim Green | 42 | London No. 1 Lake Park | |
My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park. | |||
Joe Black | 32 | Sidney No. 1 Lake Park | |
My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park. |
加载中
Name | Age | Address | |
---|---|---|---|
John Brown | 32 | New York No. 1 Lake Park | |
My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park. | |||
Jim Green | 42 | London No. 1 Lake Park | |
My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park. | |||
Joe Black | 32 | Sidney No. 1 Lake Park | |
My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park. |
加载中
Name | Age | Home phone | Address | ||
---|---|---|---|---|---|
John Brown | 32 | 0571-22098909 | 18889898989 | New York No. 1 Lake Park | |
Jim Green | 42 | 0571-22098333 | 18889898888 | London No. 1 Lake Park | |
Joe Black | 32 | 0575-22098909 | 18900010002 | Sidney No. 1 Lake Park | |
Jim Red | 18 | 18900010002 | London No. 2 Lake Park | ||
Jake White | 18 |
加载中
Name | Age | Address |
---|---|---|
60 | New York No. 1 Lake Park | |
Joe Black | 32 | Sidney No. 1 Lake Park |
加载中
Edward King 0 | 32 | London, Park Lane no. 0 |
Edward King 1 | 32 | London, Park Lane no. 1 |
Edward King 2 | 32 | London, Park Lane no. 2 |
Edward King 3 | 32 | London, Park Lane no. 3 |
Edward King 4 | 32 | London, Park Lane no. 4 |
Edward King 5 | 32 | London, Park Lane no. 5 |
Edward King 6 | 32 | London, Park Lane no. 6 |
Edward King 7 | 32 | London, Park Lane no. 7 |
Edward King 8 | 32 | London, Park Lane no. 8 |
Edward King 9 | 32 | London, Park Lane no. 9 |
Edward King 10 | 32 | London, Park Lane no. 10 |
Edward King 11 | 32 | London, Park Lane no. 11 |
Edward King 12 | 32 | London, Park Lane no. 12 |
Edward King 13 | 32 | London, Park Lane no. 13 |
Edward King 14 | 32 | London, Park Lane no. 14 |
Edward King 15 | 32 | London, Park Lane no. 15 |
Edward King 16 | 32 | London, Park Lane no. 16 |
Edward King 17 | 32 | London, Park Lane no. 17 |
Edward King 18 | 32 | London, Park Lane no. 18 |
Edward King 19 | 32 | London, Park Lane no. 19 |
Edward King 20 | 32 | London, Park Lane no. 20 |
Edward King 21 | 32 | London, Park Lane no. 21 |
Edward King 22 | 32 | London, Park Lane no. 22 |
Edward King 23 | 32 | London, Park Lane no. 23 |
Edward King 24 | 32 | London, Park Lane no. 24 |
Edward King 25 | 32 | London, Park Lane no. 25 |
Edward King 26 | 32 | London, Park Lane no. 26 |
Edward King 27 | 32 | London, Park Lane no. 27 |
Edward King 28 | 32 | London, Park Lane no. 28 |
Edward King 29 | 32 | London, Park Lane no. 29 |
Edward King 30 | 32 | London, Park Lane no. 30 |
Edward King 31 | 32 | London, Park Lane no. 31 |
Edward King 32 | 32 | London, Park Lane no. 32 |
Edward King 33 | 32 | London, Park Lane no. 33 |
Edward King 34 | 32 | London, Park Lane no. 34 |
Edward King 35 | 32 | London, Park Lane no. 35 |
Edward King 36 | 32 | London, Park Lane no. 36 |
Edward King 37 | 32 | London, Park Lane no. 37 |
Edward King 38 | 32 | London, Park Lane no. 38 |
Edward King 39 | 32 | London, Park Lane no. 39 |
Edward King 40 | 32 | London, Park Lane no. 40 |
Edward King 41 | 32 | London, Park Lane no. 41 |
Edward King 42 | 32 | London, Park Lane no. 42 |
Edward King 43 | 32 | London, Park Lane no. 43 |
Edward King 44 | 32 | London, Park Lane no. 44 |
Edward King 45 | 32 | London, Park Lane no. 45 |
Edward King 46 | 32 | London, Park Lane no. 46 |
Edward King 47 | 32 | London, Park Lane no. 47 |
Edward King 48 | 32 | London, Park Lane no. 48 |
Edward King 49 | 32 | London, Park Lane no. 49 |
加载中
加载中
Edward King 0 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 1 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 2 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 3 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 4 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 5 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 6 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 7 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 8 | 32 | London | London | London | London | London | London | London | London | action |
Edward King 9 | 32 | London | London | London | London | London | London | London | London | action |
加载中
John Brown | 1 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 2 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 3 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 4 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 5 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 6 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 7 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 8 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 9 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
John Brown | 10 | Lake Park | C | 2035 | Lake Street 42 | SoftLake Co | M |
加载中
加载中
Name | Age | Address | Action |
---|---|---|---|
Edward 0 | 32 | London Park no. 0 | Edit |
Edward 1 | 32 | London Park no. 1 | Edit |
Edward 2 | 32 | London Park no. 2 | Edit |
Edward 3 | 32 | London Park no. 3 | Edit |
Edward 4 | 32 | London Park no. 4 | Edit |
Edward 5 | 32 | London Park no. 5 | Edit |
Edward 6 | 32 | London Park no. 6 | Edit |
Edward 7 | 32 | London Park no. 7 | Edit |
Edward 8 | 32 | London Park no. 8 | Edit |
Edward 9 | 32 | London Park no. 9 | Edit |
加载中
加载中
加载中
Name | Age | Address |
---|---|---|
John Brown | 32 | New York No. 1 Lake Park |
Jim Green | 42 | London No. 1 Lake Park |
Joe Black | 32 | Sidney No. 1 Lake Park |
加载中
Company | Contact | Country |
---|---|---|
Alfreds Futterkiste | Maria Anders | Germany |
Centro comercial Moctezuma | Francisco Chang | Mexico |
Ernst Handel | Roland Mendel | Austria |
Island Trading | Helen Bennett | UK |
Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |
Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |
加载中
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | action |
加载中
Full Name | Age | Column 1 | Column 2 | Column ColumnColumn 3 | Column 4 |
---|---|---|---|---|---|
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon |
Edward King | 32 | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon | LondonLondonLondonLondonLondon |
加载中
Name | Borrow | Repayment |
---|---|---|
John Brown | 10 | 33 |
Jim Green | 100 | 0 |
Joe Black | 10 | 10 |
Jim Red | 75 | 45 |
Total | 195 | 88 |
Balance | 107 |
Light | Everything that has a beginning, has an end. |
Bamboo | Everything that has a beginning, has an end. |
Little | Everything that has a beginning, has an end. |
Light | Everything that has a beginning, has an end. |
Bamboo | Everything that has a beginning, has an end. |
Little | Everything that has a beginning, has an end. |
Light | Everything that has a beginning, has an end. |
Bamboo | Everything that has a beginning, has an end. |
Little | Everything that has a beginning, has an end. |
Light | Everything that has a beginning, has an end. |
加载中
Name | Age | Address | Action | ||
---|---|---|---|---|---|
John Brown | 12 | New York No. 1 Lake Park | Delete | ||
My name is John Brown, I am 12 years old, living in New York No. 1 Lake Park. | |||||
John Brown | 22 | New York No. 2 Lake Park | Delete | ||
My name is John Brown, I am 22 years old, living in New York No. 2 Lake Park. | |||||
John Brown | 32 | New York No. 3 Lake Park | Delete | ||
My name is John Brown, I am 32 years old, living in New York No. 3 Lake Park. | |||||
John Brown | 42 | New York No. 4 Lake Park | Delete | ||
My name is John Brown, I am 42 years old, living in New York No. 4 Lake Park. | |||||
John Brown | 52 | New York No. 5 Lake Park | Delete | ||
My name is John Brown, I am 52 years old, living in New York No. 5 Lake Park. | |||||
John Brown | 62 | New York No. 6 Lake Park | Delete | ||
My name is John Brown, I am 62 years old, living in New York No. 6 Lake Park. | |||||
John Brown | 72 | New York No. 7 Lake Park | Delete | ||
My name is John Brown, I am 72 years old, living in New York No. 7 Lake Park. | |||||
John Brown | 82 | New York No. 8 Lake Park | Delete | ||
My name is John Brown, I am 82 years old, living in New York No. 8 Lake Park. | |||||
John Brown | 92 | New York No. 9 Lake Park | Delete | ||
My name is John Brown, I am 92 years old, living in New York No. 9 Lake Park. | |||||
John Brown | 102 | New York No. 10 Lake Park | Delete | ||
My name is John Brown, I am 102 years old, living in New York No. 10 Lake Park. |
加载中
加载中
API#
nz-table#
参数 | 说明 | 类型 | 默认值 | 全局配置 |
---|---|---|---|---|
[nzData] | 数据数组 | T[] | - | |
[nzFrontPagination] | 是否在前端对数据进行分页,如果在服务器分页数据或者需要在前端显示全部数据时传入 false | boolean | true | |
[nzTotal] | 当前总数据,在服务器渲染时需要传入 | number | - | |
[nzCustomColumn] | 控制表格列的展示与排序,(开启后 nzWidthConfig 和 th 的 [nzWidth] 将不生效) | NzCustomColumn[] | - | |
[nzPageIndex] | 当前页码,可双向绑定 | number | - | |
[nzPageSize] | 每页展示多少数据,可双向绑定 | number | - | |
[nzShowPagination] | 是否显示分页器 | boolean | true | |
[nzPaginationPosition] | 指定分页显示的位置 | 'top' | 'bottom' | 'both' | bottom | |
[nzPaginationType] | 指定分页显示的尺寸 | 'default' | 'small' | default | |
[nzBordered] | 是否展示外边框和列边框 | boolean | false | ✅ |
[nzOuterBordered] | 是否显示外边框 | boolean | false | - |
[nzWidthConfig] | 表头分组时指定每列宽度,与 th 的 [nzWidth] 不可混用 | string[] | [] | |
[nzSize] | 正常或迷你类型 | 'middle' | 'small' | 'default' | 'default' | ✅ |
[nzLoading] | 页面是否加载中 | boolean | false | |
[nzLoadingIndicator] | 加载指示符 | TemplateRef<void> | - | ✅ |
[nzLoadingDelay] | 延迟显示加载效果的时间(防止闪烁) | number | 0 | |
[nzScroll] | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度:{ x: "300px", y: "300px" } | object | - | |
[nzTitle] | 表格标题 | string | TemplateRef<void> | - | |
[nzFooter] | 表格尾部 | string | TemplateRef<void> | - | |
[nzNoResult] | 无数据时显示内容 | string | TemplateRef<void> | - | |
[nzPageSizeOptions] | 页数选择器可选值 | number[] | [ 10, 20, 30, 40, 50 ] | |
[nzShowQuickJumper] | 是否可以快速跳转至某页 | boolean | false | ✅ |
[nzShowSizeChanger] | 是否可以改变 nzPageSize | boolean | false | ✅ |
[nzShowTotal] | 用于显示数据总量和当前数据范围,用法参照 Pagination 组件 | TemplateRef<{ $implicit: number, range: [ number, number ] }> | - | |
[nzItemRender] | 用于自定义页码的结构,用法参照 Pagination 组件 | TemplateRef<{ $implicit: 'page' | 'prev' | 'next', page: number }> | - | |
[nzHideOnSinglePage] | 只有一页时是否隐藏分页器 | boolean | false | ✅ |
[nzSimple] | 当添加该属性时,显示为简单分页 | boolean | - | ✅ |
[nzTemplateMode] | 模板模式,无需将数据传递给 nzData | boolean | false | |
[nzVirtualItemSize] | 虚拟滚动时每一列的高度,与 cdk itemSize 相同 | number | 0 | |
[nzVirtualMaxBufferPx] | 缓冲区最大像素高度,与 cdk maxBufferPx 相同 | number | 200 | |
[nzVirtualMinBufferPx] | 缓冲区最小像素高度,低于该值时将加载新结构,与 cdk minBufferPx 相同 | number | 100 | |
[nzVirtualForTrackBy] | 虚拟滚动数据 TrackByFunction 函数 | TrackByFunction<T> | - | |
(nzPageIndexChange) | 当前页码改变时的回调函数 | EventEmitter<number> | - | |
(nzPageSizeChange) | 页数改变时的回调函数 | EventEmitter<number> | - | |
(nzCurrentPageDataChange) | 当前页面展示数据改变的回调函数 | EventEmitter<T[]> | - | |
(nzCustomColumnChange) | 当表格重新排序后的回调 | EventEmitter<NzCustomColumn[]> | - | |
(nzQueryParams) | 当服务端分页、筛选、排序时,用于获得参数,具体见示例 | EventEmitter<NzTableQueryParams> | - |
th#
勾选属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzShowCheckbox] | 是否添加 checkbox | boolean | - |
[nzDisabled] | checkbox 是否禁用 | boolean | - |
[nzIndeterminate] | checkbox indeterminate 状态 | boolean | - |
[nzLabel] | checkbox 的可访问性标签 | string | - |
[nzChecked] | checkbox 是否被选中,可双向绑定 | boolean | - |
(nzCheckedChange) | 选中的回调 | EventEmitter<boolean> | - |
下拉选择属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzShowRowSelection] | 是否显示下拉选择 | boolean | - |
[nzSelections] | 下拉选择的内容 text 及回调函数 onSelect | Array<{ text: string, onSelect: any }> | - |
排序属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzShowSort] | 是否显示排序 | boolean | - |
[nzSortFn] | 排序函数,前端排序使用一个函数(参考 Array.sort 的 compareFunction),服务端排序时传入 true | NzTableSortFn<T> | boolean | - |
[nzSortDirections] | 支持的排序方式,取值为 'ascend' , 'descend' , null | Array<'ascend' | 'descend' | null> | ['ascend', 'descend', null] |
[nzSortOrder] | 当前排序状态,可双向绑定 | 'descend' | 'ascend' |
(nzSortOrderChange) | 排序状态改变回调 | EventEmitter<'descend' | 'ascend' | null> | - |
过滤属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzShowFilter] | 是否显示过滤 | boolean | - |
[nzFilterFn] | 前端排序时,确定筛选的运行函数,服务端排序时,传入 true | NzTableFilterFn<T> | boolean | - |
[noDataVirtualHeight] | 没有数据时内部滚动的高度,如果没有传递任何内容,则使用默认值。 | string | '182px' |
[nzFilters] | 过滤器内容, 显示数据 text ,回调函数传出 value ,设置 byDefault 以默认应用过滤规则 | Array<{ text: string; value: any; byDefault?: boolean }> | - |
[nzFilterMultiple] | 是否为多选过滤器 | boolean | true |
(nzFilterChange) | 过滤器内容选择的 value 数据回调 | EventEmitter<any[] | any> | - |
样式属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzWidth] | 指定该列宽度,表头未分组时可用 | string | - |
[nzLeft] | 左侧距离,用于固定左侧列,当为 true 时自动计算,为 false 时停止固定 | string | boolean | false |
[nzRight] | 右侧距离,用于固定右侧列,当为 true 时自动计算,为 false 时停止固定 | string | boolean | false |
[nzAlign] | 设置列内容的对齐方式 | 'left' | 'right' | 'center' | - |
[nzCellControl] | 设置列的位置,该值为 NzCustomColumn 类型中 value 字段的值 | string | - |
[nzBreakWord] | 是否折行显示 | boolean | false |
[nzEllipsis] | 超过宽度将自动省略,暂不支持和排序筛选一起使用。仅当表格布局将为 nzTableLayout="fixed" 时可用 | boolean | false |
[colSpan] | 每单元格中扩展列的数量 | number | null |
[rowSpan] | 每单元格中扩展行的数量 | number | null |
其他
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzColumnKey] | 当前列的 key,用于服务端筛选和排序使用 | string | - |
td#
勾选属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzShowCheckbox] | 是否添加 checkbox | boolean | - |
[nzDisabled] | checkbox 是否禁用 | boolean | - |
[nzIndeterminate] | checkbox indeterminate 状态 | boolean | - |
[nzLabel] | checkbox 的可访问性标签 | string | - |
[nzChecked] | checkbox 是否被选中,可双向绑定 | boolean | - |
(nzCheckedChange) | 选中的回调 | EventEmitter<boolean> | - |
[colSpan] | 单元格可横跨的列数 | number | null |
[rowSpan] | 单元格可横跨的行数 | number | null |
展开属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzShowExpand] | 是否显示展开按钮 | boolean | - |
[nzExpand] | 当前展开按钮状态,可双向绑定 | boolean | - |
[nzExpandIcon] | 自定义展开图标 | TemplateRef<void> | - |
(nzExpandChange) | 当前展开按钮状态改变回调函数 | EventEmitter<boolean> | - |
样式属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzLeft] | 左侧距离,用于固定左侧列,当为 true 时自动计算,为 false 时停止固定 | string | boolean | false |
[nzRight] | 右侧距离,用于固定右侧列,当为 true 时自动计算,为 false 时停止固定 | string | boolean | false |
[nzAlign] | 设置列内容的对齐方式 | 'left' | 'right' | 'center' | - |
[nzCellControl] | 设置列的位置,该值为 NzCustomColumn 类型中 value 字段的值 | string | - |
[nzBreakWord] | 是否折行显示 | boolean | false |
[nzEllipsis] | 超过宽度将自动省略,暂不支持和排序筛选一起使用。仅当表格布局将为 nzTableLayout="fixed" 时可用 | boolean | false |
其他
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzIndentSize] | 展示树形数据时,每层缩进的宽度,以 px 为单位 | number | - |
thead#
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
(nzSortOrderChange) | 排序状态改变回调,需要与 th 上的 nzColumnKey 同时使用 | EventEmitter<{ key: string, value: 'descend' | 'ascend' | null }> | - |
tr#
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzExpand] | 当前列是否展开,与 td 上的 nzExpand 属性配合使用 | boolean | - |
tfoot#
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzSummary] | 总结栏 | boolean | - |
[nzFixed] | 总结栏是否固定,与 nzScroll 属性配合使用 | boolean | 'top' | 'bottom' | false |
nz-filter-trigger#
用于自定义筛选功能
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
[nzDropdownMenu] | Dropdown 下拉菜单组件 | NzDropdownMenuComponent | - |
[nzVisible] | 菜单是否显示,可双向绑定 | boolean | - |
[nzActive] | 是否激活选中图标效果 | boolean | false |
[nzHasBackdrop] | 是否附带背景板 | boolean | false |
(nzVisibleChange) | 菜单显示状态改变时调用,参数为 nzVisible | EventEmitter<boolean> | - |
[nz-virtual-scroll]#
虚拟滚动时配合 ng-template
使用, 格式为: TemplateRef<{ $implicit: T, index: number }>
。
注意#
为了获得更好的性能,NG-ZORRO 所有组件都运行在 OnPush 模式下,这意味着对 @Input()
数据的 mutate 将不会生效,请使用 immutable 方式操作数组或者对象。
// 增加数据
this.dataSet = [
...this.dataSet,
{
key: `${this.i}`,
name: `Edward King ${this.i}`,
age: '32',
address: `London, Park Lane no. ${this.i}`
}
];
// 删除数据
this.dataSet = this.dataSet.filter(d => d.key !== i);
开发者也可以使用 immer 获得更好的操作体验。