From c41f3394a43708cee6b2ae18f94a0b166fc2b72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Falksk=C3=A4r?= <457523+edvard-falkskar@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:37:30 +0200 Subject: [PATCH] InteractiveTable: Add initial sort prop (#89937) --- .../src/components/InteractiveTable/InteractiveTable.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx b/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx index 0ad083f5452..c82a7bb4961 100644 --- a/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx +++ b/packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.tsx @@ -147,6 +147,10 @@ interface BaseProps { * re-renders of the table. */ fetchData?: FetchDataFunc; + /** + * Optional way to set how the table is sorted from the beginning. Must be memoized. + */ + initialSortBy?: Array>; } interface WithExpandableRow extends BaseProps { @@ -178,6 +182,7 @@ export function InteractiveTable({ renderExpandedRow, showExpandAll = false, fetchData, + initialSortBy = [], }: Props) { const styles = useStyles2(getStyles); const tableColumns = useMemo(() => { @@ -218,6 +223,7 @@ export function InteractiveTable({ .map((c) => c.id) .filter(isTruthy), ].filter(isTruthy), + sortBy: initialSortBy, }, }, ...tableHooks