-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGridPro] Add new option hideDescendantCount to Tree Data #3368
Changes from all commits
76df4bb
cc6496f
48f8056
8763627
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,23 @@ import { GridApiRef } from '../../../models/api/gridApiRef'; | |
import { GridComponentProps } from '../../../GridComponentProps'; | ||
import { | ||
GRID_TREE_DATA_GROUP_COL_DEF, | ||
GRID_TREE_DATA_GROUP_COL_DEF_FORCED_FIELDS, | ||
GRID_TREE_DATA_GROUP_COL_DEF_FORCED_PROPERTIES, | ||
} from './gridTreeDataGroupColDef'; | ||
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler'; | ||
import { GridEvents, GridEventListener } from '../../../models/events'; | ||
import { GridColDef, GridGroupingColDefOverrideParams } from '../../../models'; | ||
import { | ||
GridColDef, | ||
GridGroupingColDefOverride, | ||
GridGroupingColDefOverrideParams, | ||
} from '../../../models'; | ||
import { isSpaceKey } from '../../../utils/keyboardUtils'; | ||
import { useFirstRender } from '../../utils/useFirstRender'; | ||
import { buildRowTree, BuildRowTreeGroupingCriteria } from '../../../utils/tree/buildRowTree'; | ||
import { GridRowGroupingPreProcessing } from '../../core/rowGroupsPerProcessing'; | ||
import { gridFilteredDescendantCountLookupSelector } from '../filter'; | ||
import { GridPreProcessingGroup, useGridRegisterPreProcessor } from '../../core/preProcessing'; | ||
import { GridColumnsRawState } from '../columns/gridColumnsState'; | ||
import { GridTreeDataGroupingCell } from '../../../components'; | ||
|
||
const TREE_DATA_GROUPING_NAME = 'tree-data'; | ||
|
||
|
@@ -33,12 +38,7 @@ export const useGridTreeData = ( | |
const groupingColDef = React.useMemo<GridColDef>(() => { | ||
const propGroupingColDef = props.groupingColDef; | ||
|
||
const baseColDef: GridColDef = { | ||
...GRID_TREE_DATA_GROUP_COL_DEF, | ||
headerName: apiRef.current.getLocaleText('treeDataGroupingHeaderName'), | ||
...GRID_TREE_DATA_GROUP_COL_DEF_FORCED_FIELDS, | ||
}; | ||
let colDefOverride: Partial<GridColDef> | null | undefined; | ||
let colDefOverride: GridGroupingColDefOverride | null | undefined; | ||
|
||
if (typeof propGroupingColDef === 'function') { | ||
const params: GridGroupingColDefOverrideParams = { | ||
|
@@ -51,9 +51,20 @@ export const useGridTreeData = ( | |
colDefOverride = propGroupingColDef; | ||
} | ||
|
||
const { hideDescendantCount, ...colDefOverrideProperties } = colDefOverride ?? {}; | ||
|
||
const commonProperties: Omit<GridColDef, 'field' | 'editable'> = { | ||
...GRID_TREE_DATA_GROUP_COL_DEF, | ||
renderCell: (params) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to avoid adding properties on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sense, but when defining There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For column grouping I have other properties only usefull for the grouping column. |
||
<GridTreeDataGroupingCell {...params} hideDescendantCount={hideDescendantCount} /> | ||
), | ||
headerName: apiRef.current.getLocaleText('treeDataGroupingHeaderName'), | ||
}; | ||
|
||
return { | ||
...baseColDef, | ||
...colDefOverride, | ||
...commonProperties, | ||
...colDefOverrideProperties, | ||
...GRID_TREE_DATA_GROUP_COL_DEF_FORCED_PROPERTIES, | ||
}; | ||
}, [apiRef, props.groupingColDef]); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know what caused this modification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3343
Probably this one
I checked the NextJS example and they have this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/vercel/next.js/pull/28316/files
I think I found the PR