@mui/x-data-grid-pro
Version:
The Pro plan edition of the MUI X Data Grid components.
49 lines (47 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getParentPath = getParentPath;
exports.skipFiltering = skipFiltering;
exports.skipSorting = skipSorting;
var _xDataGrid = require("@mui/x-data-grid");
var _internals = require("@mui/x-data-grid/internals");
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: _internals.defaultGridFilterLookup.filteredRowsLookup,
filteredChildrenCountLookup,
filteredDescendantCountLookup: _internals.defaultGridFilterLookup.filteredDescendantCountLookup
};
}
function skipSorting(rowTree) {
return (0, _internals.getTreeNodeDescendants)(rowTree, _xDataGrid.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.
*
* Uses the parent node's `path` property, which stores the group keys
* representing the full path to the parent (i.e. the keys used to fetch the current node).
*/
function getParentPath(rowId, treeCreationParams) {
if (treeCreationParams.updates.type !== 'full' || !treeCreationParams.previousTree?.[rowId] || treeCreationParams.previousTree[rowId].depth < 1) {
return [];
}
const node = treeCreationParams.previousTree[rowId];
const parentId = node.parent;
if (parentId == null) {
return [];
}
const parentNode = treeCreationParams.previousTree[parentId];
if (parentNode && 'path' in parentNode) {
return parentNode.path || [];
}
return [];
}