mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 20:49:14 +08:00
Merge pull request #838 from ant-design/rowClick
[feat] add rowClick demo and doc
This commit is contained in:
commit
02f15e6b92
91
components/table/demo/on-row-click.md
Normal file
91
components/table/demo/on-row-click.md
Normal file
@ -0,0 +1,91 @@
|
||||
# 行点击事件
|
||||
|
||||
- order: 17
|
||||
- hidden: true
|
||||
|
||||
通过传入 `onRowClick` 处理表格行点击事件,函数的两个参数为 `record` 和 `index`,`index` 代表当前行在其兄弟节点中的次序
|
||||
|
||||
---
|
||||
|
||||
````jsx
|
||||
import { Table } from 'antd';
|
||||
|
||||
const onRowClick = function(record, index) {
|
||||
alert(`u click the nth(${index}) element of yourFather.children, record.name: ${record.name}`);
|
||||
};
|
||||
|
||||
const onOperationClick = function(text, record) {
|
||||
alert(`u click ${text}, record.name is ${record.name}`);
|
||||
};
|
||||
|
||||
const columns = [{
|
||||
title: '姓名',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
}, {
|
||||
title: '年龄',
|
||||
dataIndex: 'age',
|
||||
key: 'age',
|
||||
render: (text, record) => <a href="#" onClick={onOperationClick.bind(null, text, record)}>Alert: {text}, click will pop to row click</a>,
|
||||
}, {
|
||||
title: '住址',
|
||||
dataIndex: 'address',
|
||||
key: 'address',
|
||||
}];
|
||||
|
||||
const data = [{
|
||||
key: 1,
|
||||
name: 'a',
|
||||
age: 32,
|
||||
address: '我是a',
|
||||
children: [{
|
||||
key: 11,
|
||||
name: 'aa',
|
||||
age: 33,
|
||||
address: '我是aa',
|
||||
}, {
|
||||
key: 12,
|
||||
name: 'ab',
|
||||
age: 33,
|
||||
address: '我是ab',
|
||||
children: [{
|
||||
key: 121,
|
||||
name: 'aba',
|
||||
age: 33,
|
||||
address: '我是aba',
|
||||
}],
|
||||
}, {
|
||||
key: 13,
|
||||
name: 'ac',
|
||||
age: 33,
|
||||
address: '我是ac',
|
||||
children: [{
|
||||
key: 131,
|
||||
name: 'aca',
|
||||
age: 33,
|
||||
address: '我是aca',
|
||||
children: [{
|
||||
key: 1311,
|
||||
name: 'acaa',
|
||||
age: 33,
|
||||
address: '我是acaa',
|
||||
}, {
|
||||
key: 1312,
|
||||
name: 'acab',
|
||||
age: 33,
|
||||
address: '我是acab',
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
}, {
|
||||
key: 2,
|
||||
name: 'b',
|
||||
age: 32,
|
||||
address: '我是b',
|
||||
}];
|
||||
|
||||
ReactDOM.render(
|
||||
<Table columns={columns} dataSource={data} onRowClick={onRowClick} />,
|
||||
mountNode
|
||||
);
|
||||
````
|
@ -67,6 +67,8 @@ const columns = [{
|
||||
| onChange | 分页、排序、筛选变化时触发 | Function(pagination, filters, sorter) | | |
|
||||
| loading | 页面是否加载中 | Boolean | | false |
|
||||
| locale | 设置排序、过滤按钮的文字或 `title` | Object | | [默认值](https://github.com/ant-design/ant-design/issues/575#issuecomment-159169511) |
|
||||
| indentSize | 展示树形数据时,每层缩进的宽度,以 px 为单位 | Number | | 15 |
|
||||
| onRowClick | 处理行点击事件 | Function(record, index) | | 无 |
|
||||
|
||||
### Column
|
||||
|
||||
@ -83,7 +85,6 @@ const columns = [{
|
||||
| filterMultiple | 是否多选 | Boolean | | true |
|
||||
| sorter | 排序函数,本地排序使用一个函数,需要服务端排序可设为 true | Function or Boolean | | 无 |
|
||||
| colSpan | 表头列合并,设置为 0 时,不渲染 | Number | | |
|
||||
| indentSize | 展示树形数据时,每层缩进的宽度,以 px 为单位 | Number | | 15 |
|
||||
| width | 列宽度 | String or Number | | 无 |
|
||||
| className | 列的 className | String | | 无 |
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
||||
"rc-slider": "~3.3.0",
|
||||
"rc-steps": "~1.4.1",
|
||||
"rc-switch": "~1.3.1",
|
||||
"rc-table": "~3.7.1",
|
||||
"rc-table": "~3.8.0",
|
||||
"rc-tabs": "~5.6.0",
|
||||
"rc-time-picker": "~1.0.0",
|
||||
"rc-tooltip": "~3.3.0",
|
||||
|
Loading…
Reference in New Issue
Block a user