From fe98def108699200c4f53feed807260441977d36 Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Fri, 10 May 2024 23:21:02 -0500 Subject: [PATCH] Add show_search and show_quick_filters to ui.table --- plugins/ui/src/deephaven/ui/components/table.py | 4 ++++ plugins/ui/src/js/src/elements/UITable.tsx | 9 ++++++--- plugins/ui/src/js/src/elements/UITableUtils.tsx | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/ui/src/deephaven/ui/components/table.py b/plugins/ui/src/deephaven/ui/components/table.py index 9f4e8226a..e52fcd45d 100644 --- a/plugins/ui/src/deephaven/ui/components/table.py +++ b/plugins/ui/src/deephaven/ui/components/table.py @@ -18,6 +18,8 @@ def table( on_cell_double_press: CellPressCallback | None = None, on_column_press: ColumnPressCallback | None = None, on_column_double_press: ColumnPressCallback | None = None, + show_search: bool = False, + show_quick_filters: bool = False, ) -> UITable: """ Customization to how a table is displayed, how it behaves, and listen to UI events. @@ -40,6 +42,8 @@ def table( The first parameter is the column name. on_column_double_press: The callback function to run when a column is double clicked. The first parameter is the column name. + show_search: Whether to show the search bar by default. + show_quick_filters: Whether to show the quick filter bar by default. """ props = locals() del props["table"] diff --git a/plugins/ui/src/js/src/elements/UITable.tsx b/plugins/ui/src/js/src/elements/UITable.tsx index 0c137c27e..93f87a235 100644 --- a/plugins/ui/src/js/src/elements/UITable.tsx +++ b/plugins/ui/src/js/src/elements/UITable.tsx @@ -25,11 +25,12 @@ function UITable({ onColumnDoublePress, onRowPress, onRowDoublePress, - canSearch, filters, sorts, alwaysFetchColumns, table: exportedTable, + showSearchBar, + showQuickFilters, }: UITableProps): JSX.Element | null { const dh = useApi(); const [model, setModel] = useState(); @@ -114,15 +115,17 @@ function UITable({ () => ({ mouseHandlers, alwaysFetchColumns, - showSearchBar: canSearch, + showSearchBar, sorts: hydratedSorts, quickFilters: hydratedQuickFilters, + isFilterBarShown: showQuickFilters, settings, }), [ mouseHandlers, alwaysFetchColumns, - canSearch, + showSearchBar, + showQuickFilters, hydratedSorts, hydratedQuickFilters, settings, diff --git a/plugins/ui/src/js/src/elements/UITableUtils.tsx b/plugins/ui/src/js/src/elements/UITableUtils.tsx index b86dc7bb4..da36feba0 100644 --- a/plugins/ui/src/js/src/elements/UITableUtils.tsx +++ b/plugins/ui/src/js/src/elements/UITableUtils.tsx @@ -30,9 +30,10 @@ export interface UITableProps { onColumnPress?: (columnName: ColumnName) => void; onColumnDoublePress?: (columnName: ColumnName) => void; alwaysFetchColumns?: string[]; - canSearch?: boolean; filters?: Record; sorts?: DehydratedSort[]; + showSearchBar?: boolean; + showQuickFilters?: boolean; [key: string]: unknown; }