-
-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add custom selection in Table #4962
Conversation
@infeng, thanks for your PR! By analyzing the history of the files in this pull request, we identified @afc163, @benjycui and @kvetoslavnovak to be potential reviewers. |
Run |
components/table/index.zh-CN.md
Outdated
@@ -120,6 +120,9 @@ const columns = [{ | |||
| getCheckboxProps | 选择框的默认属性配置 | Function(record) | - | | |||
| onSelect | 用户手动选择/取消选择某列的回调 | Function(record, selected, selectedRows) | - | | |||
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, changeRows) | - | | |||
| onSelectInvert | 用户手动选择反选的回调 | Function(selectedRows) | - | | |||
| selections | 自定义选择项 | {key: string, text: string}[] | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text 建议支持 React.ReactNode
,因为国际化时会用到 <FormattedMesage ... />
之类
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onSelectInvert
和 selections[n].onSelect
都不需要的,都在 rowSelection.onChange
里就够了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样rowSelection.onChange
的参数需要改一下,我是想着不改变原本的属性,所以才加了onSelectInvert
和selections[n].onSelect
components/table/index.zh-CN.md
Outdated
@@ -120,6 +120,9 @@ const columns = [{ | |||
| getCheckboxProps | 选择框的默认属性配置 | Function(record) | - | | |||
| onSelect | 用户手动选择/取消选择某列的回调 | Function(record, selected, selectedRows) | - | | |||
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, changeRows) | - | | |||
| onSelectInvert | 用户手动选择反选的回调 | Function(selectedRows) | - | | |||
| selections | 自定义选择项 | {key: string, text: string}[] | - | | |||
| onSelection | 用户选择自定义选择项的回调 | Fcuntion(key, changableRowKeys) | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议 onSelection
合并为 selections[n].onSelect
,这样就不需要用到 switch
了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用switch
确实不好,我改一下
有个疑问,如果我只需要全选和反选,现在的 API 好像不怎么友好? |
现在是默认有全选和反选,如果只需要全选和反选,不需要设置什么,不过这样有一个问题是不能去除全选和反选 |
原来的使用方式要保留,然后如果不设置,就是原来的交互。 |
我觉得默认带全选和反选问题不大。 |
travis 还是挂的。 |
加些用例吧。 |
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要补充测试用例。
|
是什么问题会导致生成的snapshot不对 😂 |
因为 rc-table 发了一个 patch。 |
已加上几个测试用例 |
这个没注意到,我改一下 |
问了设计师距离,我来调整下吧。 |
官网没有全选反选的例子?只有一个选择奇数行和偶数行的例子,点击后还无效,配置项里加了rowCounterSelection无效 |
Close #2651
rowSelection.selections
that is add custom selection.rowSelection.onSelectInvert
that is callback that is called when select invert.