Browse Source

Add Table `getPopupContainer`

close #17548
close #16876
close #14864
close #14426
pull/17806/head
afc163 5 years ago
parent
commit
173859e49c
No known key found for this signature in database GPG Key ID: 5F00908D72002306
  1. 13
      components/table/Table.tsx
  2. 3
      components/table/filterDropdown.tsx
  3. 1
      components/table/index.en-US.md
  4. 1
      components/table/index.zh-CN.md
  5. 1
      components/table/interface.tsx

13
components/table/Table.tsx

@ -85,6 +85,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
locale: PropTypes.object,
dropdownPrefixCls: PropTypes.string,
sortDirections: PropTypes.array,
getPopupContainer: PropTypes.func,
};
static defaultProps = {
@ -762,15 +763,13 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
return recordKey === undefined ? index : recordKey;
};
getPopupContainer = () => {
return ReactDOM.findDOMNode(this) as HTMLElement;
};
generatePopupContainerFunc = () => {
const { scroll } = this.props;
const { scroll, getPopupContainer } = this.props;
if (getPopupContainer) {
return getPopupContainer;
}
// Use undefined to let rc component use default logic.
return scroll ? this.getPopupContainer : undefined;
return scroll ? () => ReactDOM.findDOMNode(this) as HTMLElement : undefined;
};
renderRowSelection(prefixCls: string, locale: TableLocale) {

3
components/table/filterDropdown.tsx

@ -263,7 +263,6 @@ class FilterMenu<T> extends React.Component<FilterMenuProps<T>, FilterMenuState<
confirm: this.handleConfirm,
clearFilters: this.handleClearFilters,
filters: column.filters,
getPopupContainer: (triggerNode: HTMLElement) => triggerNode.parentNode as HTMLElement,
});
}
@ -281,7 +280,7 @@ class FilterMenu<T> extends React.Component<FilterMenuProps<T>, FilterMenuState<
onSelect={this.setSelectedKeys}
onDeselect={this.setSelectedKeys}
selectedKeys={originSelectedKeys && originSelectedKeys.map(val => val.toString())}
getPopupContainer={(triggerNode: HTMLElement) => triggerNode.parentNode}
getPopupContainer={getPopupContainer}
>
{this.renderMenus(column.filters!)}
</Menu>

1
components/table/index.en-US.md

@ -87,6 +87,7 @@ const columns = [
| onExpandedRowsChange | Callback executed when the expanded rows change | Function(expandedRows) | | |
| onHeaderRow | Set props on per header row | Function(column, index) | - | |
| onRow | Set props on per row | Function(record, index) | - | |
| getPopupContainer | the render container of dropdowns in table | (triggerNode) => HTMLElement | `() => TableHtmlElement` | 3.21.0 |
#### onRow usage

1
components/table/index.zh-CN.md

@ -92,6 +92,7 @@ const columns = [
| onExpandedRowsChange | 展开的行变化时触发 | Function(expandedRows) | | |
| onHeaderRow | 设置头部行属性 | Function(column, index) | - | |
| onRow | 设置行属性 | Function(record, index) | - | |
| getPopupContainer | 设置表格内各类浮层的渲染节点,如筛选菜单 | (triggerNode) => HTMLElement | `() => TableHtmlElement` | 3.21.0 |
#### onRow 用法

1
components/table/interface.tsx

@ -190,6 +190,7 @@ export interface TableProps<T> {
style?: React.CSSProperties;
children?: React.ReactNode;
sortDirections?: SortOrder[];
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
}
export interface TableStateFilters {

Loading…
Cancel
Save