Skip to content

Commit 24887ef

Browse files
committed
Removed **props and added examples (#201)
1 parent 85e19d3 commit 24887ef

2 files changed

Lines changed: 79 additions & 5 deletions

File tree

plugins/ui/docs/README.md

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ def ui_picker_table():
348348
column_types,
349349
label="Text",
350350
on_change=set_value,
351-
selected_keys=value,
351+
selected_key=value,
352352
)
353353

354354
text = ui.text(f"Selection: {value}")
355355

356356
return ui.flex(pick_table, text, direction="column", margin=10, gap=10)
357357

358358

359-
pick_table = ui_picker_table()
359+
my_picker_table = ui_picker_table()
360360
```
361361

362362
![Use a picker to select from a table](_assets/pick_table.png)
@@ -391,19 +391,94 @@ def ui_picker_table_source():
391391
ui.item_table_source(column_types, key_column="Id", label_column="Display"),
392392
label="Text",
393393
on_change=set_value,
394-
selected_keys=value,
394+
selected_key=value,
395395
)
396396

397397
text = ui.text(f"Selection: {value}")
398398

399399
return ui.flex(pick_table, text, direction="column", margin=10, gap=10)
400400

401401

402-
pick_table_source = ui_picker_table_source()
402+
my_picker_table_source = ui_picker_table_source()
403403
```
404404

405405
![Use a picker to select from a table source](_assets/pick_table_source.png)
406406

407+
## ComboBox (string values)
408+
409+
The `ui.combo_box` component can be used to select from a list of items. It also provides a search field to filter available results. Note that the search behavior differs slightly for different data types.
410+
- Numeric types - only support exact match
411+
- Text based data types - support partial search matching
412+
- Date types support searching by different date parts (e.g. `2024`, `2024-01`, `2024-01-02`, `2024-01-02 00`, `2024-07-06 00:43`, `2024-07-06 00:43:14`, `2024-07-06 00:43:14.247`)
413+
414+
Here's a basic example for selecting from a list of string values and displaying the selected key in a text field.
415+
416+
```python
417+
from deephaven import ui
418+
419+
420+
@ui.component
421+
def ui_combo_box():
422+
value, set_value = ui.use_state("")
423+
424+
combo = ui.combo_box(
425+
"Text 1",
426+
"Text 2",
427+
"Text 3",
428+
label="Text",
429+
on_selection_change=set_value,
430+
selected_key=value,
431+
)
432+
433+
text = ui.text("Selection: " + str(value))
434+
435+
return combo, text
436+
437+
438+
my_combo_box = ui_combo_box()
439+
```
440+
441+
## ComboBox (item table source)
442+
443+
A combo_box can also take an `item_table_source`. It will use the columns specified.
444+
445+
```python
446+
import deephaven.ui as ui
447+
from deephaven import time_table
448+
import datetime
449+
450+
# Ticking table with initial row count of 200 that adds a row every second
451+
initial_row_count = 200
452+
_table = time_table(
453+
"PT1S",
454+
start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count),
455+
).update(
456+
[
457+
"Id=new Integer(i)",
458+
"Display=new String(`Display `+i)",
459+
]
460+
)
461+
462+
463+
@ui.component
464+
def ui_combo_box_item_table_source(table):
465+
value, set_value = ui.use_state("")
466+
467+
combo = ui.combo_box(
468+
ui.item_table_source(table, key_column="Id", label_column="Display"),
469+
label="Text",
470+
on_change=set_value,
471+
selected_key=value,
472+
)
473+
474+
text = ui.text(f"Selection: {value}")
475+
476+
return combo, text
477+
478+
479+
my_combo_box_item_table_source = ui_combo_box_item_table_source(_table)
480+
```
481+
407482
## ListView (string values)
408483

409484
A list view that can be used to create a list of selectable items. Here's a basic example for selecting from a list of string values and displaying the selected key in a text field.

plugins/ui/src/deephaven/ui/components/combo_box.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def combo_box(
126126
aria_details: str | None = None,
127127
UNSAFE_class_name: str | None = None,
128128
UNSAFE_style: CSSProperties | None = None,
129-
**props: Any,
130129
) -> ComboBoxElement:
131130
"""
132131
A combo box that can be used to search or select from a list. Children should be one of five types:

0 commit comments

Comments
 (0)