@mui/x-data-grid-pro
Version:
The Pro plan edition of the MUI X Data Grid components.
29 lines (28 loc) • 1.23 kB
JavaScript
import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
import { defaultGridFilterLookup, getTreeNodeDescendants } from '@mui/x-data-grid/internals';
export function skipFiltering(rowTree) {
const filteredChildrenCountLookup = {};
const nodes = Object.values(rowTree);
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
filteredChildrenCountLookup[node.id] = node.serverChildrenCount ?? 0;
}
return {
filteredRowsLookup: defaultGridFilterLookup.filteredRowsLookup,
filteredChildrenCountLookup,
filteredDescendantCountLookup: defaultGridFilterLookup.filteredDescendantCountLookup
};
}
export function skipSorting(rowTree) {
return getTreeNodeDescendants(rowTree, GRID_ROOT_GROUP_ID, false);
}
/**
* Retrieves the parent path for a row from the previous tree state.
* Used during full tree updates to maintain correct hierarchy.
*/
export function getParentPath(rowId, treeCreationParams) {
if (treeCreationParams.updates.type !== 'full' || !treeCreationParams.previousTree?.[rowId] || treeCreationParams.previousTree[rowId].depth < 1 || !('path' in treeCreationParams.previousTree[rowId])) {
return [];
}
return treeCreationParams.previousTree[rowId].path || [];
}