mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
InteractiveTable: Add initial sort prop (#89937)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user