diff --git a/src/components/streaming-table/StreamingTable.tsx b/src/components/streaming-table/StreamingTable.tsx index fb2495e..fe36eee 100644 --- a/src/components/streaming-table/StreamingTable.tsx +++ b/src/components/streaming-table/StreamingTable.tsx @@ -36,6 +36,8 @@ export type StreamingTableProps = { initialPage?: number; /** Enable sorting (default: false) */ enableSorting?: boolean; + /** Initial sorting state (default: null) */ + initialSorting?: SortingState; } & Omit; const StreamingTable = (props: StreamingTableProps) => { @@ -52,14 +54,20 @@ const StreamingTable = (props: StreamingTableProps) => { "pageSize", "initialPage", "enableSorting", + "initialSorting", ]); const store: StreamingTableStore = createStreamingTableStore(); // Sorting state - const [sortingState, setSortingState] = createSignal({ - columnId: null, - direction: null, + const [sortingState, setSortingState] = createSignal( + local.initialSorting ?? { columnId: null, direction: null } + ); + + createEffect(() => { + if (local.initialSorting) { + setSortingState(local.initialSorting); + } }); const config = {