Skip to content
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

Merged
merged 8 commits into from
Feb 23, 2017
Merged

Conversation

infeng
Copy link
Contributor

@infeng infeng commented Feb 20, 2017

Close #2651

  • add rowSelection.selections that is add custom selection.
  • add rowSelection.onSelectInvert that is callback that is called when select invert.

@mention-bot
Copy link

@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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling 3d44c01 on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@afc163
Copy link
Member

afc163 commented Feb 20, 2017

Run npm test -- -u and commit it to update snapshots.

@@ -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}[] | - |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text 建议支持 React.ReactNode,因为国际化时会用到 <FormattedMesage ... /> 之类

Copy link
Member

@afc163 afc163 Feb 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onSelectInvertselections[n].onSelect 都不需要的,都在 rowSelection.onChange 里就够了。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样rowSelection.onChange的参数需要改一下,我是想着不改变原本的属性,所以才加了onSelectInvertselections[n].onSelect

@@ -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) | - |
Copy link
Contributor

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 了。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch确实不好,我改一下

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling 443faf8 on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@benjycui
Copy link
Contributor

有个疑问,如果我只需要全选和反选,现在的 API 好像不怎么友好?

@infeng
Copy link
Contributor Author

infeng commented Feb 20, 2017

现在是默认有全选和反选,如果只需要全选和反选,不需要设置什么,不过这样有一个问题是不能去除全选和反选

@benjycui
Copy link
Contributor

现在是默认有全选和反选,如果只需要全选和反选,不需要设置什么,不过这样有一个问题是不能去除全选和反选

原来的使用方式要保留,然后如果不设置,就是原来的交互。

@afc163
Copy link
Member

afc163 commented Feb 20, 2017

我觉得默认带全选和反选问题不大。

@afc163
Copy link
Member

afc163 commented Feb 20, 2017

travis 还是挂的。

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling 243e7fe on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@afc163
Copy link
Member

afc163 commented Feb 20, 2017

加些用例吧。

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling 23ad7ec on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@benjycui
Copy link
Contributor

👍

Copy link
Member

@afc163 afc163 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要补充测试用例。

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling c4f47f8 on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling c34c0ce on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@afc163
Copy link
Member

afc163 commented Feb 23, 2017

rm -rf node_modules && npm install && npm test -- -u

@infeng
Copy link
Contributor Author

infeng commented Feb 23, 2017

是什么问题会导致生成的snapshot不对 😂

@afc163
Copy link
Member

afc163 commented Feb 23, 2017

因为 rc-table 发了一个 patch。

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 82.299% when pulling 8e586fa on infeng:feature-2.8 into 18e554f on ant-design:feature-2.8.

@infeng
Copy link
Contributor Author

infeng commented Feb 23, 2017

已加上几个测试用例

@afc163 afc163 merged commit 6d903a6 into ant-design:feature-2.8 Feb 23, 2017
@infeng infeng deleted the feature-2.8 branch February 24, 2017 17:18
@yesmeck
Copy link
Member

yesmeck commented Mar 6, 2017

这个好像跟设计稿不一样? checkbox 没对齐。

dingtalk20170306103018

@infeng
Copy link
Contributor Author

infeng commented Mar 6, 2017

这个没注意到,我改一下

@yesmeck yesmeck mentioned this pull request Mar 6, 2017
@yesmeck
Copy link
Member

yesmeck commented Mar 6, 2017

问了设计师距离,我来调整下吧。

@malaxiannv
Copy link

官网没有全选反选的例子?只有一个选择奇数行和偶数行的例子,点击后还无效,配置项里加了rowCounterSelection无效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants