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