bokeh/ipywidgets_bokeh

Ipygrid not working

MarcSkovMadsen opened this issue · 0 comments

Ipygrid is a really powerful table/ grid that would nice to be able to use with Panel. But unfortunately it does not work. Instead it raises an error.

image

Panel: 0.12.6
IpyKernel: 6.5.0
IpyWidgets_bokeh: 1.2.1
ipydatagrid: 1.1.7
bokeh: 2.4.2

Error: Could not create a view for model id 1e70e7bde1404f8e951efc9553a0289f
    y ipywidgets_bokeh.js:2
    promise callback*I</e.prototype.create_view/e.state_change< ipywidgets_bokeh.js:2
    promise callback*I</e.prototype.create_view ipywidgets_bokeh.js:2
    create_child_view ipywidgets_bokeh.js:2
    updateProcessor cellrenderer.ts:172
    initializeRenderer cellrenderer.ts:109
    render cellrenderer.ts:73
    render cellrenderer.ts:304
    state_change ipywidgets_bokeh.js:2
    promise callback*I</e.prototype.create_view/e.state_change< ipywidgets_bokeh.js:2
    promise callback*I</e.prototype.create_view ipywidgets_bokeh.js:2
    create_child_view ipywidgets_bokeh.js:2
    updateRenderers datagrid.ts:533
    render datagrid.ts:485
    state_change ipywidgets_bokeh.js:2
    promise callback*I</e.prototype.create_view/e.state_change< ipywidgets_bokeh.js:2
    promise callback*I</e.prototype.create_view ipywidgets_bokeh.js:2
    display_model ipywidgets_bokeh.js:2
    render ipywidgets_bokeh.js:2
    _render ipywidgets_bokeh.js:2
    render ipywidgets_bokeh.js:2
    render bokeh.min.js:496
    build bokeh.min.js:496
    renderTo bokeh.min.js:496
    f bokeh.min.js:584
    add_document_standalone bokeh.min.js:584
    add_document_from_session bokeh.min.js:586
    w bokeh.min.js:163
    embed_items bokeh.min.js:163
    embed_document script3:80
    fn script3:84
    fn script3:100
    safely bokeh.min.js:595
    fn script3:74
    EventListener.handleEvent* script3:104
    <anonymous> script3:105
from ipydatagrid import DataGrid
import panel as pn
import pandas as pd
from urllib.request import urlopen
import json

pn.extension("ipywidgets", sizing_mode="stretch_width")

def get_widget():

    url = "https://raw.githubusercontent.com/bloomberg/ipydatagrid/main/examples/cars.json"
    response = urlopen(url)
    json_data = response.read().decode('utf-8', 'replace')
    data = json.loads(json_data)

    df = (
        pd.DataFrame(data["data"])
        .drop("index", axis=1)
    )

    datagrid = DataGrid(df, selection_mode="cell")

    return datagrid

widget = get_widget()
component = pn.pane.IPyWidget(widget, height=500, width=500, sizing_mode="fixed")
pn.Column(
    "# IpyDatagrid",
    component,
    "is not shown",
).servable()

Run panel serve file.py --show to show investigate the error in the browser.

Crossposts: holoviz/panel#2641, https://github.com/bloomberg/ipydatagrid/issues/265d