Skip to content

Commit

Permalink
feat: ui.table functionality (#145)
Browse files Browse the repository at this point in the history
This is not ready for review but I am putting this up just in case as I
know Bender mentioned possibly working on some of the js functionality
while I am on vacation. What's implemented is not thoroughly tested,
needs to be refactored, and subject to change but I have sorts, quick
filters, and the search bar hooked up.

Example:
```
from deephaven import SortDirection
import deephaven.ui as ui
import deephaven.plot.express as dx

stocks = dx.data.stocks()

@ui.component
def searchable_filtered_sorted_table(source):
    return [
        ui.panel(
            ui.table(source)
            .sort("price", SortDirection.DESCENDING)
            .quick_filter({"side": "sell"})
            .can_search("SHOW"),
            title="Stock Table I",
        )
    ]


sti = searchable_filtered_sorted_table(stocks)
```
  • Loading branch information
jnumainville authored Jan 4, 2024
1 parent a7daf6a commit df04f29
Show file tree
Hide file tree
Showing 6 changed files with 749 additions and 19 deletions.
14 changes: 8 additions & 6 deletions plugins/ui/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1388,22 +1388,24 @@ ui_table.selection_mode(mode: SelectionMode) -> UITable
##### sort

Provide the default sort that will be used by the UI.
Can use Deephaven [SortDirection](https://deephaven.io/core/pydoc/code/deephaven.html#deephaven.SortDirection) used in
a table [sort](https://deephaven.io/core/docs/reference/table-operations/sort/) operation or`"ASC"` or `"DESC"`.

###### Syntax

```py
ui_table.sort(
order_by: str | Sequence[str],
order: SortDirection | Sequence[SortDirection] | None = None
order: TableSortDirection | Sequence[TableSortDirection] | None = None
) -> UITable
```

###### Parameters

| Parameter | Type | Description |
| ----------- | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `by` | `str \| Sequence[str]` | The column(s) to sort by. May be a single column name, or a list of column names. |
| `direction` | `SortDirection \| Sequence[SortDirection] \| None` | The sort direction(s) to use. If provided, that must match up with the columns provided. Defaults to "ASC". |
| Parameter | Type | Description |
| ----------- |--------------------------------------------------------------| ----------------------------------------------------------------------------------------------------------- |
| `by` | `str \| Sequence[str]` | The column(s) to sort by. May be a single column name, or a list of column names. |
| `direction` | `TableSortDirection \| Sequence[TableSortDirection] \| None` | The sort direction(s) to use. If provided, that must match up with the columns provided. Defaults to "ASC". |

#### ui.fragment

Expand Down Expand Up @@ -1605,7 +1607,7 @@ RowIndex = int | None
SearchMode = Literal["SHOW", "HIDE", "DEFAULT"]
SelectionMode = Literal["CELL", "ROW", "COLUMN"]
Sentinel = Any
SortDirection = Literal["ASC", "DESC"]
TableSortDirection = Union[Literal["ASC", "DESC"], SortDirection]
TableData = dict[ColumnName, ColumnData]
TransformedData = Any

Expand Down
Loading

0 comments on commit df04f29

Please sign in to comment.