shiny.ui.update_selectize#

shiny.ui.update_selectize(id, *, label=None, choices=None, selected=None, server=False, session=None)#

Change the value of a selectize.js powered input on the client.

Parameters
  • id (str) – An input id.

  • label (Optional[str]) – An input label.

  • choices (Union[List[str], Tuple[str, …], Mapping[str, Union[Tagifiable, Tag, MetadataNode, str, TagList, float, None, Dict[str, Union[str, float, bool, None]], Sequence[Union[Tagifiable, Tag, MetadataNode, str, TagList, float, None, Dict[str, Union[str, float, bool, None]], Sequence[ForwardRef]]]]], Mapping[str, Mapping[str, Union[Tagifiable, Tag, MetadataNode, str, TagList, float, None, Dict[str, Union[str, float, bool, None]], Sequence[Union[Tagifiable, Tag, MetadataNode, str, TagList, float, None, Dict[str, Union[str, float, bool, None]], Sequence[ForwardRef]]]]]], None]) – Either a list of choices or a dictionary mapping choice values to labels. Note that if a dictionary is provided, the keys are used as the (input) values so that the dictionary values can hold HTML labels. A dictionary of dictionaries is also supported, and in that case, the top-level keys are treated as <optgroup> labels.

  • selected (Union[str, List[str], None]) – The values that should be initially selected, if any.

  • server (bool) – Whether to store choices on the server side, and load the select options dynamically on searching, instead of writing all choices into the page at once (i.e., only use the client-side version of selectize.js)

  • session (Optional[Session]) – A Session instance. If not provided, it is inferred via get_current_session().

Note

The input updater functions send a message to the client, telling it to change the settings of an input object. The messages are collected and sent after all the observers (including outputs) have finished running.

The syntax of these functions is similar to the functions that created the inputs in the first place. For example, input_numeric() and update_numeric() take a similar set of arguments.

Any arguments with None values will be ignored; they will not result in any changes to the input object on the client.

For update_radio_buttons(), update_checkbox_group(), and update_select(), the set of choices can be cleared by using choices=[]. Similarly, for these inputs, the selected item can be cleared by using selected=[].

See also

input_selectize

Example

#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *

app_ui = ui.page_fluid(
    ui.input_selectize("x", "Server side selectize", choices=None, multiple=True),
)

def server(input: Inputs, output: Outputs, session: Session):
    @reactive.Effect
    def _():
        ui.update_selectize(
            "x",
            choices=[f"Foo {i}" for i in range(10000)],
            selected=["Foo 0", "Foo 1"],
            server=True,
        )


app = App(app_ui, server, debug=True)
Return type

None