InteractiveTable: Add initial sort prop (#89937)

This commit is contained in:
Edvard Falkskär
2024-07-17 09:37:30 +01:00
committed by GitHub
parent 14cd98d7fb
commit c41f3394a4
@@ -147,6 +147,10 @@ interface BaseProps<TableData extends object> {
* re-renders of the table.
*/
fetchData?: FetchDataFunc<TableData>;
/**
* Optional way to set how the table is sorted from the beginning. Must be memoized.
*/
initialSortBy?: Array<SortingRule<TableData>>;
}
interface WithExpandableRow<TableData extends object> extends BaseProps<TableData> {
@@ -178,6 +182,7 @@ export function InteractiveTable<TableData extends object>({
renderExpandedRow,
showExpandAll = false,
fetchData,
initialSortBy = [],
}: Props<TableData>) {
const styles = useStyles2(getStyles);
const tableColumns = useMemo(() => {
@@ -218,6 +223,7 @@ export function InteractiveTable<TableData extends object>({
.map((c) => c.id)
.filter(isTruthy),
].filter(isTruthy),
sortBy: initialSortBy,
},
},
...tableHooks