You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
Hi,
I'm trying to add rows using clientside_callback. I'm encountering 2 issues:
After appending the new row to the data object, the table is not refreshed with new rows. If I update cell values of already plotted cells, the display updates as expected, and if I delete a row the new rows appear. Is there a way to manually trigger a full table refresh from the clientside?
n_clicks is not reset to 0 after the clientside event has been triggered. You can see that by selecting different cells in the table. Every time you do that after having clicked new row, additional rows are inserted to the data object.
Thanks =)
import dash
import dash_table
import dash_html_components as html
from dash.dependencies import Input, Output, State
import pandas as pd
magic = pd.DataFrame(data=[[1,2,3,4],[1,2,3,4]],columns=["abra","ka","da","bra"])
app = dash.Dash()
app.layout = html.Div([
dash_table.DataTable(
id='table',
columns=[{"name": i, "id": i} for i in magic.columns],
data=magic.to_dict('records'),
editable=True,
row_deletable=True
),
html.Button('Add Row', id='editing-rows-button', n_clicks=0)
])
app.clientside_callback(
"""
function (selected,n_clicks,data,columns) {
if (n_clicks > 0) {
newRow = {}
for (i in columns) {
newRow[columns[i]['name']] = null
}
data.push(newRow)
}
console.log(n_clicks)
console.log(data)
return data
}
""",
Output('table', 'data'),
[Input('table', 'active_cell'), Input('editing-rows-button', 'n_clicks')],
[State('table', 'data'), State('table', 'columns')]
)
if __name__ == '__main__':
app.run_server(debug=True)