Hi i have a panel tabulator table running, and i want to allow a button to be clicked to add an additional row that the use then can enter data in… i know in tabulator you can use addRow, but not sure how to achieve this in panel?
I normally just reassign the value with the new dataframe to the tabular object. It is a panel parameter so it will sync automatically. There is also a streaming section in the docs that may serve your use case!
how do i reassign it? can you give me example?
All the properties listed in the docs should be re-assignable.
https://panel.holoviz.org/reference/widgets/Tabulator.html
import panel as pn
import pandas as pd
frame1 = pd.DataFrame({"A": [1, 2, 3]})
table = pn.widgets.Tabulator(value=frame1)
button = pn.widgets.Button(name="click me")
def change_data(_):
frame2 = pd.DataFrame({"A": [1, 2, 3, 4]})
table.value = frame2
button.on_click(change_data)
pn.Column(button, table).servable()
1 Like
Replacing the dataframe object is fine if its not very big. But if its big it will start to be slow to re-transfer the full dataframe to just add one row. Then you should stream new rows as described in the Tabulator - Streaming Section.