Browse Source

feat: add rowSelection.columnTitle to Table

pull/11499/merge
littleLane 6 years ago
committed by Wei Zhu
parent
commit
b23d742f1b
  1. 3
      components/table/Table.tsx
  2. 21
      components/table/__tests__/Table.rowSelection.test.js
  3. 1
      components/table/index.en-US.md
  4. 1
      components/table/index.zh-CN.md
  5. 1
      components/table/interface.tsx

3
components/table/Table.tsx

@ -708,10 +708,11 @@ export default class Table<T> extends React.Component<TableProps<T>, 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 || (
<SelectionCheckboxAll
store={this.store}
locale={locale}

21
components/table/__tests__/Table.rowSelection.test.js

@ -421,4 +421,25 @@ describe('Table.rowSelection', () => {
expect(checkbox.props().indeterminate).toBe(false);
});
});
// https://github.com/ant-design/ant-design/issues/11042
it('add columnTitle for rowSelection', () => {
const wrapper = mount(
<Table
columns={columns}
dataSource={data}
rowSelection={{
columnTitle: '多选',
}}
/>
);
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('单选');
});
});

1
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` |

1
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 |

1
components/table/interface.tsx

@ -78,6 +78,7 @@ export interface TableRowSelection<T> {
fixed?: boolean;
columnWidth?: string | number;
selectWay?: TableSelectWay;
columnTitle?: string | React.ReactNode;
}
export type SortOrder = 'descend' | 'ascend';
export interface SorterResult<T> {

Loading…
Cancel
Save