Skip to content

Commit 61cd83f

Browse files
vberschMarcusNotheis
authored andcommitted
feat(AnalyticalTable): enable passing additional props to react-table (#131)
1 parent 8cc9ec3 commit 61cd83f

File tree

1 file changed

+15
-5
lines changed
  • packages/main/src/components/AnalyticalTable

1 file changed

+15
-5
lines changed

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface ColumnConfiguration {
2222
vAlign?: VerticalAlign;
2323
canResize?: boolean;
2424
minWidth?: number;
25-
2625
[key: string]: any;
2726
}
2827

@@ -65,6 +64,11 @@ export interface TableProps extends CommonProps {
6564
noDataText?: string;
6665
stickyHeader?: boolean;
6766
onSort?: (e?: Event) => void;
67+
/**
68+
* additional options which will be passed to [react-table´s useTable hook](https://github.com/tannerlinsley/react-table/blob/master/docs/api.md#table-options)
69+
*/
70+
reactTableOptions?: object;
71+
tableHooks?: Array<() => any>;
6872
}
6973

7074
const useStyles = createUseStyles<JSSTheme, keyof ReturnType<typeof styles>>(styles);
@@ -100,7 +104,9 @@ export const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, re
100104
selectable,
101105
onRowSelected,
102106
stickyHeader,
103-
onSort
107+
onSort,
108+
reactTableOptions,
109+
tableHooks
104110
} = props;
105111

106112
const [selectedRow, setSelectedRow] = useState(null);
@@ -188,13 +194,15 @@ export const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, re
188194
columns,
189195
data,
190196
defaultColumn,
191-
state: tableState
197+
state: tableState,
198+
...reactTableOptions
192199
},
193200
useFilters,
194201
useGroupBy,
195202
useSortBy,
196203
useExpanded,
197-
useTableStyling
204+
useTableStyling,
205+
...tableHooks
198206
);
199207

200208
const minimumRows = useMemo(() => {
@@ -333,5 +341,7 @@ AnalyticalTable.defaultProps = {
333341
pivotBy: [],
334342
NoDataComponent: DefaultNoDataComponent,
335343
noDataText: 'No Data',
336-
stickyHeader: true
344+
stickyHeader: true,
345+
reactTableOptions: {},
346+
tableHooks: []
337347
};

0 commit comments

Comments
 (0)