Delete row on Datatable

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',
                       width=100, height=400)

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

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

add_btn = Button(label="Add", button_type="default")
clear_btn = Button(label="Clear", button_type="default")

curdoc().add_root(row(data_table, column(add_btn, clear_btn)))

You will have to update the whole data source since right now there’s no other way to remove a row… A bit of discussion on it:

Yes, i knew it. And i have did it in my example, i must delete Datatable row then when CDS row is empty.

Not sure what you mean. You cannot use patch and del for this. You actually have to do something like data['x'] = [x for i, x in enumerate(data['x']) where i != indx].

This is what I need, thanks.

I have a question. Why i can’t use del and patch in that case ? del is deleting item of list

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.