mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 11:18:14 +08:00
feat: add rowSelection.columnTitle to Table
This commit is contained in:
parent
6199340b5f
commit
b23d742f1b
@ -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}
|
||||
|
@ -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('单选');
|
||||
});
|
||||
});
|
||||
|
@ -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` |
|
||||
|
@ -154,6 +154,7 @@ const columns = [{
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| columnWidth | 自定义列表选择框宽度 | string\|number | - |
|
||||
| columnTitle | 自定义列表选择框标题 | string\|React.ReactNode | - |
|
||||
| fixed | 把选择框列固定在左边 | boolean | - |
|
||||
| getCheckboxProps | 选择框的默认属性配置 | Function(record) | - |
|
||||
| hideDefaultSelections | 去掉『全选』『反选』两个默认选项 | boolean | false |
|
||||
|
@ -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…
Reference in New Issue
Block a user