mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-27 06:51:34 +08:00
feat: Table rowSelection support align (#53127)
This commit is contained in:
parent
fb5c942925
commit
15cf94ff18
@ -496,4 +496,18 @@ describe('Table', () => {
|
||||
fireEvent.mouseEnter(cell);
|
||||
expect(container.querySelectorAll('.ant-table-cell-row-hover')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('rowSelection should support align', () => {
|
||||
const wrapper = render(
|
||||
<Table
|
||||
columns={[{ title: 'Name', dataIndex: 'name' }]}
|
||||
dataSource={[{ key: 1, name: 'Jack' }]}
|
||||
rowSelection={{ align: 'right' }}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(wrapper.container.querySelector('.ant-table-selection-column')).toHaveStyle({
|
||||
textAlign: 'right',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -709,6 +709,7 @@ const useSelection = <RecordType extends AnyObject = AnyObject>(
|
||||
title: renderColumnTitle(),
|
||||
render: renderSelectionCell,
|
||||
onCell: rowSelection.onCell,
|
||||
align: rowSelection.align,
|
||||
[INTERNAL_COL_DEFINE]: { className: columnCls },
|
||||
};
|
||||
|
||||
|
@ -265,6 +265,7 @@ Properties for row selection.
|
||||
|
||||
| Property | Description | Type | Default | Version |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| align | Set the alignment of selection column | `left` \| `right` \| `center` | `left` | 5.25.0 |
|
||||
| checkStrictly | Check table row precisely; parent row and children rows are not associated | boolean | true | 4.4.0 |
|
||||
| columnTitle | Set the title of the selection column | ReactNode \| (originalNode: ReactNode) => ReactNode | - | |
|
||||
| columnWidth | Set the width of the selection column | string \| number | `32px` | |
|
||||
|
@ -267,6 +267,7 @@ const columns = [
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| align | 设置选择列的对齐方式 | `left` \| `right` \| `center` | `left` | 5.25.0 |
|
||||
| checkStrictly | checkable 状态下节点选择完全受控(父子数据选中状态不再关联) | boolean | true | 4.4.0 |
|
||||
| columnTitle | 自定义列表选择框标题 | ReactNode \| (originalNode: ReactNode) => ReactNode | - | |
|
||||
| columnWidth | 自定义列表选择框宽度 | string \| number | `32px` | |
|
||||
|
@ -242,6 +242,8 @@ export interface TableRowSelection<T = AnyObject> {
|
||||
columnWidth?: string | number;
|
||||
columnTitle?: React.ReactNode | ((checkboxNode: React.ReactNode) => React.ReactNode);
|
||||
checkStrictly?: boolean;
|
||||
/** Set the alignment of the selection column */
|
||||
align?: 'left' | 'center' | 'right';
|
||||
renderCell?: (
|
||||
value: boolean,
|
||||
record: T,
|
||||
|
Loading…
Reference in New Issue
Block a user