When I substitute the simple callback in the example for adding rows to a datatable for a clientside callback, the table does not expand and display the new row. If I delete a row with the row_deletable argument the table will update showing all of the added rows. However, when I run it through a normal callback everything works as shown in the example. I’m guessing there’s something else that must be done with the component via clientside to get it to update?
### THIS DOES NOT WORK
clientside_callback(
"""
function(n1, data, columns) {
if (n1) {
const newRow = columns.reduce((obj, col) => {
obj[col.id] = null;
return obj;
}, {});
data.push(newRow);
}
return data
}
""",
Output({'type': f'{self.instance_name}_debt_scheduler'}, 'data'),
Input({'type': f'{self.instance_name}_debt_scheduler_add_row'}, 'n_clicks'),
State({'type': f'{self.instance_name}_debt_scheduler'}, 'data'),
State({'type': f'{self.instance_name}_debt_scheduler'}, 'columns'),
pervent_initial_call=True
)
#### THIS WORKS
@callback(
Output({'type': f'{self.instance_name}_debt_scheduler'}, 'data'),
Input({'type': f'{self.instance_name}_debt_scheduler_add_row'}, 'n_clicks'),
State({'type': f'{self.instance_name}_debt_scheduler'}, 'data'),
State({'type': f'{self.instance_name}_debt_scheduler'}, 'columns'),
pervent_initial_call=True
)
def add_row(n_clicks, rows, columns):
if n_clicks:
rows.append({c['id']: '' for c in columns})
return rows