react-data-grid
react-data-grid copied to clipboard
Allow passing extra props to Cell via Row component
Use case
When a column header is selected, we want to highlight all cells in the column by applying a different class name. However, currently the class applied to the cell is only calculated when the Cell component renders, and there isn't a good way to force a specific cell to re-render via the Row component.
Proposed solution
Add a method to the Column type to allow additional props to be passed to the Cell. Additional props are already supported in the Cell component and are applied to the wrapper div.
interface Column<TRow, TSummaryRow = unknown> {
// ...
readonly cellWrapperProps?: Maybe<Omit<React.HTMLAttributes<HTMLDivElement>, 'style' | 'children'> | ((row: TRow) => Maybe<Omit<React.HTMLAttributes<HTMLDivElement>, 'style' | 'children'>>)>;
// ...
}
This way, to force a re-render we can e.g. pass a prop like data-col-selected="true".