Skip to content

feat: ComboBox - @deephaven/jsapi-components#2077

Merged
bmingles merged 7 commits intodeephaven:mainfrom
bmingles:2074-combobox-jsapi-2
Jul 3, 2024
Merged

feat: ComboBox - @deephaven/jsapi-components#2077
bmingles merged 7 commits intodeephaven:mainfrom
bmingles:2074-combobox-jsapi-2

Conversation

@bmingles
Copy link
Copy Markdown
Contributor

@bmingles bmingles commented Jun 13, 2024

Jsapi support for ComboBox. Includes some splitting out of existing Picker logic to make code re-usable.

Should be testable with plugins PR deephaven/deephaven-plugins#588
I have also deployed an alpha 0.83.1-alpha-combobox.8 if you need it, although should only matter for types I think.

from deephaven import empty_table, ui, time_table
import datetime


# Change this to test different data types
key_column="Timestamp"


initial_row_count=5 * 8760 # 5 years in hours

# Tick every 6 hours (makes it easier to test Timestamp filters for a whole day like `2024-01-02`)
_items = time_table("PT6H", start_time=datetime.datetime.now() - datetime.timedelta(hours=initial_row_count)).update([
    # Timestamp column also implicitly included in `time_table`
    "Int=new Integer(i)",
    "Long=new Long(i)",
    "BigInt=new java.math.BigInteger(``+i)",
    "String=new String(`a`+i * 1000)",
])


@ui.component
def ui_combo_box(items):
    value, set_value = ui.use_state("")

    combo = ui.combo_box(
        ui.item_table_source(
            items,
            key_column=key_column,
            label_column=key_column,
        ),
        label=key_column,
        on_selection_change=set_value,
        menu_trigger="focus",
        selected_key=value,
    )

    # Show current selection in a ui.text component
    text = ui.text("Selection: " + str(value))

    return combo, text


my_combo_box = ui_combo_box(_items)

There is a known issue with inconsistent open as you type for table data sources.
#2115

resolves #2074

@bmingles bmingles force-pushed the 2074-combobox-jsapi-2 branch from 3465f98 to c0407f6 Compare June 27, 2024 18:28
// Copy table so we can apply filters without affecting the original table.
// (Note that this call is not actually applying any filters. Filter will be
// applied in `useSearchableViewportData`.)
const { data: tableCopy } = usePromiseFactory(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mofojed for reference, I think this is where we could apply addition filters as part of @AkshatJawne partition table work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess it might make sense to just add it to this PR, but I'm fine either way

Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

Only thing that needs updating is the PR description
Show passing in a ui.item_table_data_source instead of passing in props for key_column directly on combo_box.

@bmingles bmingles requested a review from mofojed July 3, 2024 14:18
@bmingles bmingles merged commit 115e057 into deephaven:main Jul 3, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 3, 2024
@bmingles bmingles deleted the 2074-combobox-jsapi-2 branch July 3, 2024 14:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComboBox - @deephaven/jsapi-components

2 participants