Skip to content
Discussion options

You must be logged in to vote

Hi @gtato,

This is a bit tricky, because the filter function is implemented in JavaScript and not meant to be replaced:
https://github.com/evnchn/nicegui/blob/230983fd92b5eb0183653b8e1a69351a4d8fb123/nicegui/elements/select.js#L26-L32

But with some custom JavaScript we can monkey patch it:

@ui.page('/')
def main_page():
    select = ui.select(['a_service', 'b_service', 'c_service', 'service'], with_input=True)
    ui.run_javascript(f'''
        const select = getElement({select.id});
        select.findFilteredOptions = function() {{
            const needle = this.$el.querySelector("input[type=search]")?.value.toLocaleLowerCase();
            return this.initialOptions.filter((v) => Stri…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gtato
Comment options

Answer selected by gtato
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants