Skip to content

feat: DH-21841: Add a way to set table sort state from ui.table.#1358

Open
SimonVutov wants to merge 12 commits into
mainfrom
feat-DH-21841-Add-a-way-to-set-table-sort-state-from-`ui.table`-
Open

feat: DH-21841: Add a way to set table sort state from ui.table.#1358
SimonVutov wants to merge 12 commits into
mainfrom
feat-DH-21841-Add-a-way-to-set-table-sort-state-from-`ui.table`-

Conversation

@SimonVutov

Copy link
Copy Markdown

Adds programmatic UI sort state support to ui.table.

This introduces ui.TableSort and a new sorts argument on ui.table, serializing sort descriptors to the existing iris-grid shape: column, direction, and isAbs. The frontend hydrates these descriptors and applies them to IrisGrid, preferring explicit ui.table sorts over persisted client sort state.

Includes unit coverage for sort serialization and invalid directions, plus a manual app fixture for validating programmatic table sorting.

Demo

Running the following code:

from deephaven import ui, new_table
from deephaven.column import int_col, string_col

data = new_table([
    string_col("Name", ["R01", "R02", "R03", "R04", "R05", "R06"]),
    string_col("Category", ["B", "A", "B", "A", "C", "C"]),
    int_col("SepalLength", [51, -149, 64, 58, -32, 58]),
])

t_mixed_sort_list = ui.table(
    data,
    sorts=[
        "Category",
        ui.TableSort(column="Name", direction="DESC"),
        ui.TableSort(column="SepalLength", direction="ASC", is_abs=True),
    ],
)

t_string_sort = ui.table(
    data,
    sorts="Name",
)

Creates the following tables:
Screenshot 2026-06-10 at 1 13 49 PM
Screenshot 2026-06-10 at 1 13 54 PM
Screenshot 2026-06-10 at 1 13 58 PM

@SimonVutov SimonVutov self-assigned this Jun 10, 2026
@SimonVutov SimonVutov force-pushed the feat-DH-21841-Add-a-way-to-set-table-sort-state-from-`ui.table`- branch 2 times, most recently from 4b4e12f to d63f1b9 Compare June 10, 2026 17:17
@SimonVutov SimonVutov marked this pull request as draft June 10, 2026 17:17
@SimonVutov SimonVutov force-pushed the feat-DH-21841-Add-a-way-to-set-table-sort-state-from-`ui.table`- branch from d63f1b9 to c52c256 Compare June 10, 2026 17:19
@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

2 similar comments
@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

@SimonVutov SimonVutov force-pushed the feat-DH-21841-Add-a-way-to-set-table-sort-state-from-`ui.table`- branch from c52c256 to 03a7efd Compare June 10, 2026 17:25
@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

@SimonVutov SimonVutov requested a review from mofojed June 11, 2026 19:20
@SimonVutov SimonVutov marked this pull request as ready for review June 11, 2026 19:20
@SimonVutov SimonVutov requested a review from dsmmcken June 11, 2026 19:20

@mofojed mofojed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also write the docs for this. Add to the ui/docs/components/table.md doc

@SimonVutov SimonVutov requested a review from mofojed June 12, 2026 13:11
@github-actions github-actions Bot requested a review from margaretkennedy June 12, 2026 13:11
Comment thread plugins/ui/docs/components/table.md Outdated

![Example of quick filters](../_assets/table_quick_filter.png)

## Sort state

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Sort state
## Sort

Comment thread plugins/ui/docs/components/table.md Outdated
- A `ui.TableSort` object
- A list mixing column names and `ui.TableSort` objects

When you pass `sorts`, those values take precedence over persisted client sort state.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be true. Settings sorts should set the sorts state, and then the user can change those sorts and if they reload, those sorts should persist.

You can test this with filters, e.g.

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

_stocks = dx.data.stocks()

t2 = ui.table( # Filters applied when table is opened on the client
    _stocks,
    show_quick_filters=True,
    quick_filters={
        "Sym": "CAT",
        "Exchange": "NYPE",
        "Price": ">=100"
    },
    sorts="Side"
)

Disable the option "Close Panels on Disconnect" in the console menu:

Image

Change one of the filters (e.g. >=100 to >=50)

Then refresh the browser. The >=50 will remain.

Comment on lines +290 to +291
sorts: The sorts to apply as UI state on load.
These are UI-controlled sorts (similar to reverse) rather than engine-transformed table data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the wording of this comment to be more in line with quick filters, e.g. The sorts to apply to the table.

Comment on lines 644 to 647
// If sorts are explicitly provided by ui.table, prefer them over persisted state.
if (sorts !== undefined) {
mergedProps.sorts = hydratedSorts;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. I don't think you should need to make any changes here.

Right now, after creating the table with ui.table, I can't change the sorts by clicking on a column header which is wrong. The user should be able to change the sorts after the fact, and those should persist.

Comment thread tests/app.d/tests.app Outdated
file_15=ui_home_screen.py
file_16=ui_routing.py
file_17=ui_events.py
file_18=ui_table_programmatic_sort.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new file, just add to ui_table.py. There should also be matching updates in ui_table.spec.ts.

@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

@SimonVutov SimonVutov requested a review from mofojed June 12, 2026 15:14
@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

@mofojed mofojed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not able to change the sorts when opening a table with sorts applied. User should be able to change the sorts from the UI

- A list mixing column names and `ui.TableSort` objects

When you pass `sorts`, those values take precedence over persisted client sort state.
When you pass `sorts`, those values seed the initial client sort state. If the user changes the sort, that client state is persisted and restored on reload.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let Don and Margaret review the docs, but this wording is weird to me and inconsistent with how we describe features (like with Quick filters).

@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

@github-actions

Copy link
Copy Markdown

ui docs preview (Available for 14 days)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants