Skip to content

Commit

Permalink
feat: Add ui.table reverse prop (deephaven#629)
Browse files Browse the repository at this point in the history
Fixes deephaven#607

The concern I had about reverse/sort order is that it does matter, but
we only apply a post-sort reverse in the UI via the reverse action.

We do however not have that plumbed up properly in IrisGrid (we define
pre-sort, but don't use it and don't properly apply the reverse pre-sort
if it's specified). But it works for what we want in ui.table

```py
from deephaven import ui
from deephaven.plot import express as dx

_stocks = dx.data.stocks()

stocks_reversed = ui.table(
    _stocks,
    reverse=True
)
```
  • Loading branch information
mattrunyon authored Jul 16, 2024
1 parent f7978a2 commit e56424c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
30 changes: 16 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def table(
quick_filters: dict[ColumnName, QuickFilterExpression] | None = None,
show_quick_filters: bool = False,
show_search: bool = False,
reverse: bool = False,
front_columns: list[ColumnName] | None = None,
back_columns: list[ColumnName] | None = None,
frozen_columns: list[ColumnName] | None = None,
Expand Down Expand Up @@ -59,6 +60,7 @@ def table(
quick_filters: The quick filters to apply to the table. Dictionary of column name to filter value.
show_quick_filters: Whether to show the quick filter bar by default.
show_search: Whether to show the search bar by default.
reverse: Whether to reverse the table rows. Applied after any sorts.
front_columns: The columns to pin to the front of the table. These will not be movable by the user.
back_columns: The columns to pin to the back of the table. These will not be movable by the user.
frozen_columns: The columns to freeze by default at the front of the table.
Expand Down
1 change: 1 addition & 0 deletions plugins/ui/src/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@deephaven/jsapi-bootstrap": "^0.85.1",
"@deephaven/jsapi-components": "^0.85.1",
"@deephaven/jsapi-types": "^1.0.0-dev0.35.0",
"@deephaven/jsapi-utils": "^0.85.2",
"@deephaven/log": "^0.85.0",
"@deephaven/plugin": "^0.85.1",
"@deephaven/react-hooks": "^0.85.0",
Expand Down
6 changes: 6 additions & 0 deletions plugins/ui/src/js/src/elements/UITable/UITable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
IrisGridUtils,
} from '@deephaven/iris-grid';
import { useApi } from '@deephaven/jsapi-bootstrap';
import { TableUtils } from '@deephaven/jsapi-utils';
import type { dh } from '@deephaven/jsapi-types';
import Log from '@deephaven/log';
import { getSettings, RootState } from '@deephaven/redux';
Expand All @@ -35,6 +36,7 @@ export function UITable({
table: exportedTable,
showSearch: showSearchBar,
showQuickFilters,
reverse,
frontColumns,
backColumns,
frozenColumns,
Expand Down Expand Up @@ -165,6 +167,9 @@ export function UITable({
sorts: hydratedSorts,
quickFilters: hydratedQuickFilters,
isFilterBarShown: showQuickFilters,
reverseType: reverse
? TableUtils.REVERSE_TYPE.POST_SORT
: TableUtils.REVERSE_TYPE.NONE,
settings,
onContextMenu,
}) satisfies Partial<IrisGridProps>,
Expand All @@ -175,6 +180,7 @@ export function UITable({
showQuickFilters,
hydratedSorts,
hydratedQuickFilters,
reverse,
settings,
onContextMenu,
]
Expand Down
1 change: 1 addition & 0 deletions plugins/ui/src/js/src/elements/UITable/UITableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type UITableProps = {
sorts?: DehydratedSort[];
showSearch: boolean;
showQuickFilters: boolean;
reverse: boolean;
frontColumns?: string[];
backColumns?: string[];
frozenColumns?: string[];
Expand Down

0 comments on commit e56424c

Please sign in to comment.