Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does itables block rendering of ui elements? #181

Closed
vnijs opened this issue May 20, 2023 · 2 comments · Fixed by #183
Closed

Does itables block rendering of ui elements? #181

vnijs opened this issue May 20, 2023 · 2 comments · Fixed by #183

Comments

@vnijs
Copy link

vnijs commented May 20, 2023

itables looks really great. Thanks for another great tool @mwouts!

I tried using itables in a shiny-for-python app and noticed that ui elements were not being rendered. Not sure where this issue is coming from but wanted to get your thoughts.

app_ui2 works fine but app_ui1 does not show the ui_rvar dropdown in the "Blocked" tab.

from shiny import App, ui, render
import pandas as pd
from itables import to_html_datatable as DT
from itables.sample_dfs import get_dict_of_test_dfs

app_ui1 = ui.page_fluid(
    ## no dropdown shown in "blocked" tab
    ## is it possible that itables blocks the ui_rvar output from rendering?
    ui.navset_tab(
        *[ui.nav(name, ui.HTML(DT(df))) for name, df in get_dict_of_test_dfs().items()],
        ui.nav(
            "Blocked",
            ui.output_ui("ui_rvar"),
        ),
    )
)

app_ui2 = ui.page_fluid(
    ## works fine without itables tabs
    ui.output_ui("ui_rvar"),
)


def server(input, output, session):
    @output(id="ui_rvar")
    @render.ui
    def ui_rvar():
        data = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
        df_cols = {c: f"{c} ({data[c].dtype})" for c in data.columns}
        return ui.input_select(
            id="rvar",
            label="Response Variable",
            selected=None,
            choices=df_cols,
        )


app = App(app_ui1, server)
# app = App(app_ui2, server)
@mwouts
Copy link
Owner

mwouts commented May 21, 2023

Hey @vnijs , thank you for your kind words, and also for documenting this. I confirm the issue, but I have no idea where it comes from, so I have reported it at py-shiny, we will see if they have any suggestions on how to address this.

@mwouts
Copy link
Owner

mwouts commented Jun 11, 2023

Finally the fix was as simple as no importing jQuery. I will soon release a new version of itables==1.5.3.

As the documentation states, you will now have to use from itables.shiny import DT rather than to_html_datatables (DT calls to_html_datatables with an additional argument import_jquery=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants