diff --git a/components/table/Table.tsx b/components/table/Table.tsx index db68ddaaf2..df0465b8a4 100755 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -708,10 +708,11 @@ export default class Table extends React.Component, TableState< className: selectionColumnClass, fixed: rowSelection.fixed, width: rowSelection.columnWidth, + title: rowSelection.columnTitle, }; if (rowSelection.type !== 'radio') { const checkboxAllDisabled = data.every((item, index) => this.getCheckboxPropsByItem(item, index).disabled); - selectionColumn.title = ( + selectionColumn.title = selectionColumn.title || ( { expect(checkbox.props().indeterminate).toBe(false); }); }); + + // https://github.com/ant-design/ant-design/issues/11042 + it('add columnTitle for rowSelection', () => { + const wrapper = mount( + + ); + expect(wrapper.find('thead tr span').at(0).text()).toBe('多选'); + wrapper.setProps({ + rowSelection: { + type: 'radio', + columnTitle: '单选', + }, + }); + expect(wrapper.find('thead tr span').at(0).text()).toBe('单选'); + }); }); diff --git a/components/table/index.en-US.md b/components/table/index.en-US.md index 8f2c1f31c9..16c04cc589 100644 --- a/components/table/index.en-US.md +++ b/components/table/index.en-US.md @@ -154,6 +154,7 @@ Properties for row selection. | Property | Description | Type | Default | | -------- | ----------- | ---- | ------- | | columnWidth | Set the width of the selection column | string\|number | - | +| columnTitle | Set the title of the selection column | string\|React.ReactNode | - | | fixed | Fixed selection column on the left | boolean | - | | getCheckboxProps | Get Checkbox or Radio props | Function(record) | - | | hideDefaultSelections | Remove the default `Select All` and `Select Invert` selections | boolean | `false` | diff --git a/components/table/index.zh-CN.md b/components/table/index.zh-CN.md index 2e08e90394..18fcc69da5 100644 --- a/components/table/index.zh-CN.md +++ b/components/table/index.zh-CN.md @@ -154,6 +154,7 @@ const columns = [{ | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | columnWidth | 自定义列表选择框宽度 | string\|number | - | +| columnTitle | 自定义列表选择框标题 | string\|React.ReactNode | - | | fixed | 把选择框列固定在左边 | boolean | - | | getCheckboxProps | 选择框的默认属性配置 | Function(record) | - | | hideDefaultSelections | 去掉『全选』『反选』两个默认选项 | boolean | false | diff --git a/components/table/interface.tsx b/components/table/interface.tsx index c197408ce8..4b4b712fd0 100644 --- a/components/table/interface.tsx +++ b/components/table/interface.tsx @@ -78,6 +78,7 @@ export interface TableRowSelection { fixed?: boolean; columnWidth?: string | number; selectWay?: TableSelectWay; + columnTitle?: string | React.ReactNode; } export type SortOrder = 'descend' | 'ascend'; export interface SorterResult {