Skip to content

Commit b1a16f5

Browse files
[DataGridPro] Data source: Allow expanding groups with unknown children (@MBilalShafi) (#17149)
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com> Co-authored-by: Bilal Shafi <bilalshafidev@gmail.com>
1 parent d07c5f7 commit b1a16f5

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

packages/x-data-grid-premium/src/components/GridDataSourceGroupingCriteriaCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function GridGroupingCriteriaCellIcon(props: GridGroupingCriteriaCellIconProps)
7373
);
7474
}
7575

76-
return descendantCount > 0 ? (
76+
return descendantCount === -1 || descendantCount > 0 ? (
7777
<rootProps.slots.baseIconButton
7878
size="small"
7979
onClick={handleClick}
@@ -105,7 +105,7 @@ export function GridDataSourceGroupingCriteriaCell(props: GridGroupingCriteriaCe
105105

106106
let descendantCount = 0;
107107
if (row) {
108-
descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
108+
descendantCount = rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0;
109109
}
110110

111111
let cellContent: React.ReactNode;

packages/x-data-grid-pro/src/components/GridDataSourceTreeDataGroupingCell.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ function GridTreeDataGroupingCellIcon(props: GridTreeDataGroupingCellIconProps)
8080
</div>
8181
);
8282
}
83-
return descendantCount > 0 ? (
83+
84+
return descendantCount === -1 || descendantCount > 0 ? (
8485
<rootProps.slots.baseIconButton
8586
size="small"
8687
onClick={handleClick}
@@ -112,7 +113,7 @@ export function GridDataSourceTreeDataGroupingCell(props: GridTreeDataGroupingCe
112113

113114
let descendantCount = 0;
114115
if (row) {
115-
descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
116+
descendantCount = rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0;
116117
}
117118

118119
return (

0 commit comments

Comments
 (0)