☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Delete row on Datatable

Community Supportserver
FreeRP
FreeRP

How i can remove empty row ? I want to remove row, then when cells is empty.
When i click on ‘clear’ button the cells is empty, but row is exist.

from bokeh.layouts import column, row
from bokeh.plotting import curdoc
from bokeh.models import Tabs, ColumnDataSource, DataTable, \
                         TableColumn, Button

table_data = {'cell':[]}
table_src = ColumnDataSource(table_data)
data_table = DataTable(source=table_src, columns=[TableColumn(field='cell',
                                                             title='cell')],
                       width=100, height=400)

def add_callback():
    new_data_table = {'cell':[1]}
    table_src.stream(new_data_table)

def clear_callback():
    indx = len(table_src.data['cell']) - 1
    print(indx)
    if indx >= 0:
        table_src.patch({'cell':[(indx, None)]})
        del table_src.data['cell'][indx]

add_btn = Button(label="Add", button_type="default")
clear_btn = Button(label="Clear", button_type="default")
add_btn.on_click(add_callback)
clear_btn.on_click(clear_callback)

curdoc().add_root(row(data_table, column(add_btn, clear_btn)))
⌁   Link to post
Bryan
Bryan

All columns of a CDS should always all have exactly the same length at all times. Breaking that assumption (e.g. by deleting items from one column at a time) results in undefined behavior and is unsupported.

⌁   Link to post

End of archived discussion · Replies are disabled