CellContent
Reference
CellContentis aBoxthat centres its content vertically. The standard drill-down grid wraps every cell and every column header in it.- Use it, with
Text, in therenderCellandrenderHeaderof 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
-
children- Type:
ReactNode - Description: The cell or header content.
- Type:
-
style/height/ otherBoxprops- Description: Passed to the underlying
Box. For a body cell the standard grid uses{ width: '100%', height: '100%', padding: 5 }; for a header it usesheight="100%".
- Description: Passed to the underlying
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} />;
}