Skip to content

Commit

Permalink
type the demo
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Feb 4, 2022
1 parent 40e1fd7 commit f12d3ef
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,77 @@ const CustomGridTreeDataGroupingCell = (props) => {
);
};

CustomGridTreeDataGroupingCell.propTypes = {
/**
* The column field of the cell that triggered the event.
*/
field: PropTypes.string.isRequired,
/**
* The grid row id.
*/
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
/**
* The row model of the row that the current cell belongs to.
*/
row: PropTypes.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: PropTypes.shape({
/**
* The id of the row children.
* @default []
*/
children: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
),
/**
* Current expansion status of the row.
* @default false
*/
childrenExpanded: PropTypes.bool,
/**
* 0-based depth of the row in the tree.
*/
depth: PropTypes.number.isRequired,
/**
* The field used to group the children of this row.
* Is `null` if no field has been used to group the children of this row.
*/
groupingField: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.string])
.isRequired,
/**
* The key used to group the children of this row.
*/
groupingKey: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.bool,
]).isRequired,
/**
* The grid row id.
*/
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
/**
* If `true`, this node has been automatically added to fill a gap in the tree structure.
* @default false
*/
isAutoGenerated: PropTypes.bool,
/**
* The row id of the parent (null if this row is a top level row).
*/
parent: PropTypes.oneOfType([
PropTypes.oneOf([null]),
PropTypes.number,
PropTypes.string,
]).isRequired,
}).isRequired,
/**
* The cell value, but if the column has valueGetter, use getValue.
*/
value: PropTypes.any.isRequired,
};

const rows = [
{
id: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
GridEvents,
GridToolbarContainer,
GridToolbarExport,
GridRenderCellParams
} from '@mui/x-data-grid-pro';
import { styled } from '@mui/material/styles';
import { Box, Button } from '@mui/material';
Expand All @@ -25,7 +26,7 @@ const isNavigationKey = (key) =>
key.indexOf('Page') === 0 ||
key === ' ';

const CustomGridTreeDataGroupingCell = (props) => {
const CustomGridTreeDataGroupingCell = (props: GridRenderCellParams) => {
const { id, field, rowNode, row, value } = props;
const apiRef = useGridApiContext();
const filteredDescendantCountLookup = useGridSelector(
Expand Down

0 comments on commit f12d3ef

Please sign in to comment.