From 502ae06f9d59a39b80e07389c48af585e1b19ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=AF=E4=B8=80?= Date: Mon, 11 Jan 2016 11:37:36 +0800 Subject: [PATCH 1/2] [feat] add rowClick demo and doc --- components/table/demo/on-row-click.md | 90 +++++++++++++++++++++++++++ components/table/index.md | 3 +- package.json | 2 +- 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 components/table/demo/on-row-click.md diff --git a/components/table/demo/on-row-click.md b/components/table/demo/on-row-click.md new file mode 100644 index 0000000000..626ce519f4 --- /dev/null +++ b/components/table/demo/on-row-click.md @@ -0,0 +1,90 @@ +# 行点击事件 + +- order: 17 + +通过传入 `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) => Alert: {text}, click will pop to row click, +}, { + 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( + , + mountNode +); +```` diff --git a/components/table/index.md b/components/table/index.md index a10b469e5e..86426c3bf7 100644 --- a/components/table/index.md +++ b/components/table/index.md @@ -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 | | 无 | diff --git a/package.json b/package.json index fe08f25d7a..9d5818e224 100644 --- a/package.json +++ b/package.json @@ -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", From 1ca51cbd5cf43aead9ea3cc258f7729f36966704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=AF=E4=B8=80?= Date: Mon, 11 Jan 2016 12:09:12 +0800 Subject: [PATCH 2/2] [update] hide onRowClick --- components/table/demo/on-row-click.md | 1 + 1 file changed, 1 insertion(+) diff --git a/components/table/demo/on-row-click.md b/components/table/demo/on-row-click.md index 626ce519f4..e5139e6858 100644 --- a/components/table/demo/on-row-click.md +++ b/components/table/demo/on-row-click.md @@ -1,6 +1,7 @@ # 行点击事件 - order: 17 +- hidden: true 通过传入 `onRowClick` 处理表格行点击事件,函数的两个参数为 `record` 和 `index`,`index` 代表当前行在其兄弟节点中的次序