adazzle / react-data-grid

Feature-rich and customizable data grid React component
https://adazzle.github.io/react-data-grid/
Other
6.81k stars 2.17k forks source link

Group by custom cell component losing the custom component #3318

Open ofirrifo opened 10 months ago

ofirrifo commented 10 months ago

Describe the bug

When I group by custom cell component it lose the custom component and it just show value.

To Reproduce

Take a look on the example There is custom cell that represent colors and once I group by this column I lose the custom cell component and just see the value

Link to code example: example

Expected behavior

Environment

Additional context

RahulARanger commented 1 month ago

you can try the renderGroupCell prop in columns. once you group by cell, grouped column will have grouped cell.

in your src.App.tsx you can add these lines (for example)

export function ColorGroupedCell(props: any) {
  return (
    <div style={{ backgroundColor: props.childRows[0].color }}>{props.childRows[0].color}</div>
  );
}

export const columns: Column<Row>[] = [
  { key: 'id', name: 'ID', sortable: true },
  { key: 'name', name: 'name' },
  { key: 'color', name: 'color', renderCell: ColorCell , renderGroupCell: ColorGroupedCell},
];