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

[BUG] TableColumn visible property is not working if a column is added after the DataTable is created #13857

Open
GillesFa opened this issue May 1, 2024 · 0 comments
Labels

Comments

@GillesFa
Copy link
Contributor

GillesFa commented May 1, 2024

Software versions

Python version : 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)]
IPython version : 8.17.2
Tornado version : 6.3.3
Bokeh version : 3.4.1
BokehJS static path : C:\Users\gilles.faure\AppData\Local\miniconda3\envs\EO_py3.11\Lib\site-packages\bokeh\server\static
node.js version : (not installed)
npm version : (not installed)
jupyter_bokeh version : (not installed)
Operating system : Windows-10-10.0.19045-SP0

Browser name and version

MicrosoftEdge

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

Hi,
I need to add TableColumn(s) to a DataTable after the table was created. The column gets added and shown (see the minimal example added).
I am expecting to be able to change the visibility of this new column.

Observed behavior

When I change the “visible” property nothing happens (The column stays visible at all time).

Example code

from bokeh.models import ColumnDataSource
from bokeh.models import DataTable
from bokeh.models import TableColumn
from bokeh.models import NumberFormatter
from bokeh.models import Toggle
from bokeh.layouts import row
from bokeh.plotting import show
from bokeh.io import curdoc


source = ColumnDataSource(data=dict())
columns = {
    "name": TableColumn(field="name", title="Employee Name"),
    "salary": TableColumn(field="salary", title="Income", formatter=NumberFormatter(format="$0,0.00")),
    "years_experience": TableColumn(field="years_experience", title="Experience (years)"),
}

data_table = DataTable(source=source, columns=list(columns.values()), width=800)


toggle1 = Toggle(label='add column')
def cb1(attr, old, new):
    if 'test' not in columns:
        source.data['test'] = ['test1']
        columns['test'] = TableColumn(field="test", title="test")
        data_table.columns.append(columns["test"])
toggle1.on_change('active', cb1)

toggle2 = Toggle(label='column visibility')
def cb2(attr, old, new):
    if 'test' in columns:
        columns['test'].visible = toggle2.active
toggle2.on_change('active', cb2)


layout=row(data_table, toggle1, toggle2)


curdoc().add_root(layout)
curdoc().title = "Data-Table Bokeh Server"

source.data = {
    'name'             : ['name1'],
    'salary'           : [20],
    'years_experience' : [15],
}

Stack traceback or browser console output

No response

Screenshots

No response

@GillesFa GillesFa added the TRIAGE label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant