I have two tables next to each other.
The user is supposed to input words in each of them.
The callback function uses both text lists as separate inputs, and outputs something based on the two.
After entering something to the first table, and when I click on the following cell, the focus jumps to the second table.
Here is the code that I’m having this issue with:
import json
import dash
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div([
html.Div([
dt.DataTable(id='products_table',
editable=True,
rows=[{'': ''} for num in range(10)],
columns=['Products']),
], style={'width': '48%', 'display': 'inline-block'}),
html.Div([
dt.DataTable(id='words_table',
editable=True,
rows=[{'': ''} for num in range(10)],
columns=['Words']),
], style={'width': '48%', 'display': 'inline-block', 'float': 'right'}),
html.Div(id='output_df')
])
@app.callback(Output('output_df', 'children'),
[Input('products_table', 'rows'),
Input('words_table', 'rows')])
def generate_kw_df(products, words, match_types=['Exact', 'Phrase'], campaign_name='Campaign'):
product_list = list(set([d.get('Products').strip() for d in products if 'Products' in d]))
word_list = list(set([d.get('Words').strip() for d in words if 'Words' in d]))
return json.dumps(list(zip(product_list, word_list)))
if __name__ == '__main__':
app.run_server()