-
Notifications
You must be signed in to change notification settings - Fork 59
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
How to display iTables in panel? #337
Comments
Hey @jpedrick , at this stage (v2.2.3) I would recommend to use our Jupyter Widget in Panel, see the example below. Let me know how it works for you! NB: Please leave the issue open - I will at least add this to the documentation, and maybe later on develop a specific Panel component. # app.py, run with 'panel serve app.py --show'
import panel as pn
from world_bank_data import get_regions
from itables.widget import ITable
df = get_regions()
# Initialize Panel extension
pn.extension('itables')
# Create an ITable widget
itable_widget = ITable(df)
# Create a Panel layout
layout = pn.Column(
"# Sample Panel Application with ITable",
itable_widget
)
# Serve the application
layout.servable() |
Hi @mwouts , thanks for the quick reply. I'm running into a couple of issues:
I want to export this notebook as a static HTML document as well, so |
I see. Re 1. I am still experimenting with panel, so yes that line might well be superfluous. Re 2. yes the Re using HTML in a more or less direct way, I see that Panel's documentation on the HTML pane says:
That might explain why we can't use import html
import panel as pn
from itables import to_html_datatable
from itables.sample_dfs import get_countries
# Inspired from https://panel.holoviz.org/reference/panes/HTML.html#html-documents
# 1. Generate and escape the HTML datatable
df = get_countries(html=False)
escaped_html = html.escape(to_html_datatable(df))
layout = pn.Column(
# 2. Display the table within an iframe
pn.pane.HTML(
f'<iframe srcdoc="{escaped_html}" style="height:100%; width:100%" frameborder="0"></iframe>',
# 3. It is unfortunate that we need to hardcode the height
height=500,
sizing_mode="stretch_width",
)
)
layout.servable() Still I think that either the |
I'd like to embed an itable in panel, however I'm not quite sure how to do it.
I've tried the following:
I just get the following:
The text was updated successfully, but these errors were encountered: