Skip to content

Commit

Permalink
[feat] Table widged: pass getRowCell as prop (#2349)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
Co-authored-by: Rui Wang <64480766+albatross97@users.noreply.github.com>
  • Loading branch information
igorDykhta and albatross97 committed Oct 2, 2023
1 parent 1f169df commit a9181f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/src/common/data-table/index.tsx
Expand Up @@ -218,7 +218,7 @@ interface GetRowCellProps {
/*
* This is an accessor method used to generalize getting a cell from a data row
*/
const getRowCell = (
const defaultGetRowCell = (
{dataContainer, columns, column, colMeta, rowIndex, sortOrder}: GetRowCellProps,
formatter
) => {
Expand Down Expand Up @@ -407,6 +407,7 @@ export interface DataTableProps {
sortOrder?: number[] | null;
showStats?: boolean;
hasCustomScrollBarStyle?: boolean;
getRowCell?: (renderDataCellProps: GetRowCellProps, formatter: any) => string | number;
}

interface DataTableState {
Expand Down Expand Up @@ -504,6 +505,7 @@ function DataTableFactory(HeaderCell: ReturnType<typeof HeaderCellFactory>) {
scaleCellsToWidth = debounce(this.doScaleCellsToWidth, 300);

renderDataCell = (columns, isPinned, props: DataTableProps) => {
const getRowCell = this.props.getRowCell ?? defaultGetRowCell;
return cellInfo => {
const {columnIndex, key, style, rowIndex} = cellInfo;
const {dataContainer, colMeta} = props;
Expand Down

0 comments on commit a9181f6

Please sign in to comment.