|
@@ -73,7 +73,8 @@ export interface BodyProps extends BaseProps {
|
|
rowExpandable?: RowExpandable<Record<string, any>>;
|
|
rowExpandable?: RowExpandable<Record<string, any>>;
|
|
renderExpandIcon: (record: Record<string, any>, isNested: boolean) => ReactNode | null;
|
|
renderExpandIcon: (record: Record<string, any>, isNested: boolean) => ReactNode | null;
|
|
headerRef?: React.MutableRefObject<HTMLDivElement> | ((instance: any) => void);
|
|
headerRef?: React.MutableRefObject<HTMLDivElement> | ((instance: any) => void);
|
|
- onScroll?: VirtualizedOnScroll
|
|
|
|
|
|
+ onScroll?: VirtualizedOnScroll;
|
|
|
|
+ keepDOM?: boolean;
|
|
}
|
|
}
|
|
|
|
|
|
export interface BodyState {
|
|
export interface BodyState {
|
|
@@ -488,6 +489,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
index,
|
|
index,
|
|
rowKey,
|
|
rowKey,
|
|
virtualized,
|
|
virtualized,
|
|
|
|
+ displayNone
|
|
} = props;
|
|
} = props;
|
|
let key = getRecordKey(record, rowKey);
|
|
let key = getRecordKey(record, rowKey);
|
|
|
|
|
|
@@ -516,6 +518,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
virtualized={virtualized}
|
|
virtualized={virtualized}
|
|
key={genExpandedRowKey(key)}
|
|
key={genExpandedRowKey(key)}
|
|
cellWidths={this.cellWidths}
|
|
cellWidths={this.cellWidths}
|
|
|
|
+ displayNone={displayNone}
|
|
/>
|
|
/>
|
|
);
|
|
);
|
|
};
|
|
};
|
|
@@ -595,7 +598,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
* @returns {ReactNode[]} renderedRows
|
|
* @returns {ReactNode[]} renderedRows
|
|
*/
|
|
*/
|
|
renderGroupedRows = () => {
|
|
renderGroupedRows = () => {
|
|
- const { groups, dataSource: data, rowKey, expandedRowKeys } = this.props;
|
|
|
|
|
|
+ const { groups, dataSource: data, rowKey, expandedRowKeys, keepDOM } = this.props;
|
|
const { flattenedColumns } = this.context;
|
|
const { flattenedColumns } = this.context;
|
|
const groupsInData = new Map();
|
|
const groupsInData = new Map();
|
|
const renderedRows: ReactNode[] = [];
|
|
const renderedRows: ReactNode[] = [];
|
|
@@ -635,7 +638,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
);
|
|
);
|
|
|
|
|
|
// Render the grouped content when the group is expanded
|
|
// Render the grouped content when the group is expanded
|
|
- if (expanded) {
|
|
|
|
|
|
+ if (expanded || keepDOM) {
|
|
const dataInGroup: any[] = [];
|
|
const dataInGroup: any[] = [];
|
|
|
|
|
|
group.forEach((recordKey: string) => {
|
|
group.forEach((recordKey: string) => {
|
|
@@ -649,20 +652,21 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
/**
|
|
/**
|
|
* Render the contents of the group row
|
|
* Render the contents of the group row
|
|
*/
|
|
*/
|
|
- renderedRows.push(this.renderBodyRows(dataInGroup));
|
|
|
|
|
|
+ renderedRows.push(this.renderBodyRows(dataInGroup, undefined, [], !expanded));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
return renderedRows;
|
|
return renderedRows;
|
|
};
|
|
};
|
|
|
|
|
|
- renderBodyRows(data: Record<string, any>[] = [], level = 0, renderedRows: ReactNode[] = []) {
|
|
|
|
|
|
+ renderBodyRows(data: Record<string, any>[] = [], level = 0, renderedRows: ReactNode[] = [], displayNone = false) {
|
|
const {
|
|
const {
|
|
rowKey,
|
|
rowKey,
|
|
expandedRowRender,
|
|
expandedRowRender,
|
|
expandedRowKeys,
|
|
expandedRowKeys,
|
|
childrenRecordName,
|
|
childrenRecordName,
|
|
rowExpandable,
|
|
rowExpandable,
|
|
|
|
+ keepDOM
|
|
} = this.props;
|
|
} = this.props;
|
|
|
|
|
|
const hasExpandedRowRender = typeof expandedRowRender === 'function';
|
|
const hasExpandedRowRender = typeof expandedRowRender === 'function';
|
|
@@ -684,6 +688,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
...this.props,
|
|
...this.props,
|
|
columns: flattenedColumns,
|
|
columns: flattenedColumns,
|
|
expandBtnShouldInRow,
|
|
expandBtnShouldInRow,
|
|
|
|
+ displayNone,
|
|
record,
|
|
record,
|
|
key,
|
|
key,
|
|
level,
|
|
level,
|
|
@@ -693,7 +698,8 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
|
|
|
|
// render expand row
|
|
// render expand row
|
|
const expanded = isExpanded(expandedRowKeys, key);
|
|
const expanded = isExpanded(expandedRowKeys, key);
|
|
- if (hasExpandedRowRender && rowExpandable && rowExpandable(record) && expanded) {
|
|
|
|
|
|
+ const shouldRenderExpandedRows = expanded || keepDOM;
|
|
|
|
+ if (hasExpandedRowRender && rowExpandable && rowExpandable(record) && shouldRenderExpandedRows) {
|
|
const currentExpandRow = this.renderExpandedRow({
|
|
const currentExpandRow = this.renderExpandedRow({
|
|
...this.props,
|
|
...this.props,
|
|
columns: flattenedColumns,
|
|
columns: flattenedColumns,
|
|
@@ -701,6 +707,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
index,
|
|
index,
|
|
record,
|
|
record,
|
|
expanded,
|
|
expanded,
|
|
|
|
+ displayNone: displayNone || !expanded,
|
|
});
|
|
});
|
|
/**
|
|
/**
|
|
* If expandedRowRender returns falsy, this expanded row will not be rendered
|
|
* If expandedRowRender returns falsy, this expanded row will not be rendered
|
|
@@ -712,8 +719,8 @@ class Body extends BaseComponent<BodyProps, BodyState> {
|
|
}
|
|
}
|
|
|
|
|
|
// render tree data
|
|
// render tree data
|
|
- if (recordHasChildren && expanded) {
|
|
|
|
- const nestedRows = this.renderBodyRows(recordChildren, level + 1);
|
|
|
|
|
|
+ if (recordHasChildren && shouldRenderExpandedRows) {
|
|
|
|
+ const nestedRows = this.renderBodyRows(recordChildren, level + 1, [], displayNone || !expanded);
|
|
renderedRows.push(...nestedRows);
|
|
renderedRows.push(...nestedRows);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -838,7 +845,9 @@ export interface RenderExpandedRowProps {
|
|
index?: number;
|
|
index?: number;
|
|
rowKey?: RowKey<Record<string, any>>;
|
|
rowKey?: RowKey<Record<string, any>>;
|
|
virtualized?: Virtualized;
|
|
virtualized?: Virtualized;
|
|
- level?: number
|
|
|
|
|
|
+ level?: number;
|
|
|
|
+ keepDOM?: boolean;
|
|
|
|
+ displayNone?: boolean;
|
|
}
|
|
}
|
|
|
|
|
|
export interface RenderSectionRowProps {
|
|
export interface RenderSectionRowProps {
|