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)))