feat: DH-21841: Add a way to set table sort state from ui.table.#1358
feat: DH-21841: Add a way to set table sort state from ui.table.#1358SimonVutov wants to merge 12 commits into
ui.table.#1358Conversation
4b4e12f to
d63f1b9
Compare
d63f1b9 to
c52c256
Compare
|
ui docs preview (Available for 14 days) |
c52c256 to
03a7efd
Compare
|
ui docs preview (Available for 14 days) |
mofojed
left a comment
There was a problem hiding this comment.
You should also write the docs for this. Add to the ui/docs/components/table.md doc
|
|
||
|  | ||
|
|
||
| ## Sort state |
There was a problem hiding this comment.
| ## Sort state | |
| ## Sort |
| - 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. |
There was a problem hiding this comment.
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:
Change one of the filters (e.g. >=100 to >=50)
Then refresh the browser. The >=50 will remain.
| sorts: The sorts to apply as UI state on load. | ||
| These are UI-controlled sorts (similar to reverse) rather than engine-transformed table data. |
There was a problem hiding this comment.
Change the wording of this comment to be more in line with quick filters, e.g. The sorts to apply to the table.
| // If sorts are explicitly provided by ui.table, prefer them over persisted state. | ||
| if (sorts !== undefined) { | ||
| mergedProps.sorts = hydratedSorts; | ||
| } |
There was a problem hiding this comment.
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.
| file_15=ui_home_screen.py | ||
| file_16=ui_routing.py | ||
| file_17=ui_events.py | ||
| file_18=ui_table_programmatic_sort.py |
There was a problem hiding this comment.
Instead of creating a new file, just add to ui_table.py. There should also be matching updates in ui_table.spec.ts.
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
mofojed
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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).
… and t_programmatic_sort_abs_desc
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
Adds programmatic UI sort state support to
ui.table.This introduces
ui.TableSortand a newsortsargument onui.table, serializing sort descriptors to the existing iris-grid shape:column,direction, andisAbs. The frontend hydrates these descriptors and applies them toIrisGrid, preferring explicitui.tablesorts 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:
Creates the following tables:


