
Security News
Frontier AI Is Now Critical Infrastructure
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.
amos-table
Advanced tools
展示行列数据。
指定表格的数据源 dataSource 为一个数组。
const dataSource = [
{
key: '1',
name: 'ilex',
age: 16,
address: '雁塔区电子城街道'
},
{
key: '2',
name: 'ray',
age: 18,
address: '长安区郭杜街道'
},
{
key: '3',
name: 'iray',
age: 18,
address: '曲江'
}
];
const columns = [
{
title: '姓名',
dataIndex: 'name',
key: 'name'
},
{
title: '年龄',
dataIndex: 'age',
key: 'age'
},
{
title: '住址',
dataIndex: 'address',
key: 'address'
}
];
<Table dataSource={dataSource} columns={columns} />
| params | type | default | description |
|---|---|---|---|
| rowSelection | Object | null | 列表项是否可选择,配置项 |
| pagination | Object | 分页器,配置项参考 pagination,设为 false 时不显示分页 | |
| size | String | default | 正常或迷你类型,default or small |
| dataSource | Array | 数据数组 | |
| columns | Array | - | 表格列的配置描述,具体项见下表 |
| rowKey | String or Function(record, index):string | 'key' | 表格行 key 的取值,可以是字符串或一个函数 |
| rowClassName | Function(record, index):string | - | 表格行的类名 |
| expandedRowRender | Function | - | 额外的展开行 |
| defaultExpandedRowKeys | Array | - | 默认展开的行 |
| expandedRowKeys | Array | - | 展开的行,控制属性 |
| onChange | Function(pagination, filters, sorter) | 分页、排序、筛选变化时触发 | |
| loading | Boolean | false | 页面是否加载中 |
| locale | Object | filterConfirm: '确定', filterReset: '重置', emptyText: '暂无数据' | 默认文案设置,目前包括排序、过滤、空数据文案 |
| indentSize | Number | 15 | 展示树形数据时,每层缩进的宽度,以 px 为单位 |
| onRowClick | Function(record, index) | - | 处理行点击事件 |
| useFixedHeader | Boolean | false | 是否固定表头 |
| bordered | Boolean | false | 是否展示外边框和列边框 |
| showHeader | Boolean | true | 是否显示表头 |
| footer | Function(currentPageData) | - | 表格底部自定义渲染函数 |
| scroll | Object | - | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度:{{ x: true, y: 300 }} |
| params | type | default | description |
|---|---|---|---|
| showColumnPicker | boolen | false | 是否展示actionbar |
| checkboxColumnKey | String | selection-column | 表格checkbox列所在的key |
| width | Number | 600 | 宽 |
| locale | Object | {customeColumn: '自定义列', more: '更多'} | 本地化 |
| defaultColumns | array | - | 不可去掉或隐藏的列,columns dataIndex |
列描述数据对象,是 columns 中的一项。
| params | type | default | description |
|---|---|---|---|
| title | String or React.Element | - | 列头显示文字 |
| key | String | - | React 需要的 key,建议设置 |
| dataIndex | String | - | 列数据在数据项中对应的 key,支持 a.b.c 的嵌套写法 |
| render | Function(text, record, index) {} | - | 生成复杂数据的渲染函数,参数分别为当前行的值,当前行数据,行索引,@return里面可以设置表格行/列合并 |
| filters | Array | - | 表头的筛选菜单项 |
| onFilter | Function | - | 本地模式下,确定筛选的运行函数 |
| filterMultiple | Boolean | true | 是否多选 |
| filterDropdown | React.Element | - | 可以自定义筛选菜单,此函数只负责渲染图层,需要自行编写各种交互 |
| sorter | Function or Boolean | - | 排序函数,本地排序使用一个函数,需要服务端排序可设为 true |
| sorterMultiple | Number or null | - | 是否支持多列排序,设置为 null 或者不设置,则不支持多列排序。设置为 具体的 number 时,表示多列排序的优先级 |
| colSpan | Number | 表头列合并,设置为 0 时,不渲染 | |
| width | String or Number | - | 列宽度 |
| className | String | - | 列的 className |
| fixed | Boolean or String | false | 列是否固定,可选 true(等效于 left) 'left' 'right' |
| filteredValue | Array | - | 筛选的受控属性,外界可用此控制列的筛选状态,值为已筛选的 value 数组 |
| sortOrder | Boolean or String | - | 排序的受控属性,外界可用此控制列的排序,可设置为 'ascend' 'descend' false |
选择功能的配置。
| params | type | default | description |
| ------ | ------ | ------ |- ------ |
| type | String | checkbox | 多选/单选,checkbox or radio |
| selectedRowKeys | Array | 指定选中项的 key 数组,需要和 onChange 进行配合 |
| onChange | Function(selectedRowKeys, selectedRows) | - | 选中项发生变化的时的回调 |
| getCheckboxProps | Function(record) | - | 选择框的默认属性配置 |
| onSelect | Function(record, selected, selectedRows) | - | 用户手动选择/取消选择某列的回调 |
| onSelectAll | Function(selected, selectedRows, changeRows) | - | 用户手动选择/取消选择所有列的回调 |
| params | description | type | default |
|---|---|---|---|
| current | number | - | 当前页数 |
| defaultCurrent | number | 1 | 默认的当前页数 |
| total | number | 0 | 数据总数 |
| defaultPageSize | number | 10 | 默认的每页条数 |
| pageSize | number | - | 每页条数 |
| onChange | Function(page, pageSize) | noop | 页码改变的回调,参数是改变后的页码及每页条数 |
| showSizeChanger | boolean | false | 是否可以改变 pageSize |
| pageSizeOptions | string[] / ['10', '20', '30', '40'] | 指定每页可以显示多少条 | |
| onShowSizeChange | Function(current, size) | noop | pageSize 变化的回调 |
| showQuickJumper | boolean | false | 是否可以快速跳转至某页 |
| size | string | "" | 当为「small」时,是小尺寸分页 |
| simple | boolean | - | 当添加该属性时,显示为简单分页 |
| showTotal | Function(total, range) | - | 用于显示数据总量和当前数据顺序 |
| itemRender | `(page, type: 'page' | 'prev' | 'next') => React.ReactNode` |
按照 React 的 规范,所有的组件数组必须绑定 key。在 Table 中,dataSource 和 columns 里的数据值都需要指定 key 值。对于 dataSource 默认将每列数据的 key 属性作为唯一的标识。
如果你的数据没有这个属性,务必使用 rowKey 来指定数据列的主键。若没有指定,控制台会出现以下的提示,表格组件也会出现各类奇怪的错误。
设置 key 方式:
// 比如你的数据主键是 uid
return <Table rowKey="uid" />;
// 或
return <Table rowKey={record => record.uid} />;
Table#sorterMultipleFAQs
amos table
The npm package amos-table receives a total of 42 weekly downloads. As such, amos-table popularity was classified as not popular.
We found that amos-table demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.