Skip to main content

CellContent

Reference​

  • CellContent is a Box that centres its content vertically. The standard drill-down grid wraps every cell and every column header in it.
  • Use it, with Text, in the renderCell and renderHeader of a custom grid so the padding, text overflow and tooltips look the same as in every other grid.
  • Any other prop is passed to the underlying Box.

Props​

  1. children

    • Type: ReactNode
    • Description: The cell or header content.
  2. style / height / other Box props

    • Description: Passed to the underlying Box. For a body cell the standard grid uses { width: '100%', height: '100%', padding: 5 }; for a header it uses height="100%".

Usage Example​

function Example() {
const { protrakComponents } = React.useContext(customWidgetContext);
const { MUIGrid, CellContent, Text } = protrakComponents;

const cellStyle = { width: '100%', height: '100%', padding: 5 };
const overflow = { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' };

const columns = [
{
field: 'name',
headerName: 'Name',
flex: 1,
renderHeader: () => (
<CellContent height="100%">
<Text fontWeight="bold" title="Name">Name</Text>
</CellContent>
),
renderCell: (params) => (
<CellContent style={cellStyle}>
<Text style={overflow}>{params.row.name || '-'}</Text>
</CellContent>
),
},
];

return <MUIGrid data={items} columns={columns} />;
}