-
-
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
[DataGrid] Prepare the tree structure for grouping sorting / filtering + multi field grouping #3301
Conversation
…g + multi field grouping
*/ | ||
value: PropTypes.shape({ | ||
rowNode: PropTypes.shape({ |
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.
This prop doesn't need to be resolved. Add it to:
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.
@m4theushw those transpiled files do not apply the generateProptypes
config but another one stored on formattedTSDemos
I will do, a follow up PR trying to unify both 👍
There is one point I do not understand. In the code you modified, you replace |
@alexfauquette Those hooks pre-process the data to transform them into the For const rows = params.ids
.map((rowId) => ({
id: rowId,
path: props.getTreeDataPath!(params.idRowsLookup[rowId]).map(
(key): BuildRowTreeGroupingCriteria => ({ key, field: null }),
),
}))
.sort((a, b) => a.path.length - b.path.length); For params.ids.forEach((rowId) => {
const row = params.idRowsLookup[rowId];
groupingColumnsModel.forEach((groupedByField) => {
const { key } = getCellGroupingCriteria({
row,
id: rowId,
colDef: columnsLookup[groupedByField],
field: groupedByField,
});
const groupingFieldsDistinctKeys = distinctValues[groupedByField];
if (key != null && !groupingFieldsDistinctKeys.map[key.toString()]) {
groupingFieldsDistinctKeys.map[key.toString()] = true;
groupingFieldsDistinctKeys.list.push(key);
}
});
});
const rows = params.ids.map((rowId) => {
const row = params.idRowsLookup[rowId];
const parentPath = groupingColumnsModel
.map((groupingField) =>
getCellGroupingCriteria({
row,
id: rowId,
colDef: columnsLookup[groupingField],
field: groupingField,
}),
)
.filter((cell) => cell.key != null);
return {
path: [...parentPath, { key: rowId.toString(), field: null }],
id: rowId,
};
}); To go back to the demo example:
|
Needs to be merged before next release
Extracted from #3277
Breaking compared to #2725 but not breaking compared to any released version.
Replace
rowNode.groupingValue
withrowNode.groupingKey
androwNode.groupingField
. I was relying on the depth, but for the grouping columns I want to handle unbalanced groups so I need to store both the key and the field (see https://www.ag-grid.com/javascript-data-grid/grouping-unbalanced-groups/). The goal is to differentiate two grouping criteria being at the same depth but from a different field. For instance when grouping[{ director: 'A', company: 'B' }, { director: null, company: 'A' }
by['director', 'company']
, both will haveA
as the grouping key of depth 0 but not from the same field.Pass the
groupingKey
on thevalueGetter
of the grouping cell to prepare for sorting / filtering and access directly therowNode
on the component for renderingReduce the depth-margin on the grouping cell based on a feedback of @oliviertassinari (the 3 Argos diffs come from there)