Let’s try this again and see if this post will go through or not.
As the title says I am trying to update the second table based on the selection on the first table. I have gotten it working for the first selection, but for any selections after that, the displayed data will not change. I am not sure what I am doing wrong. Any help that you guys can provide would be greatly appreciated. I have attached the code below in the hopes that one of you can see what I have done wrong.
######################### CODE #########################
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output
import pandas as pd
from gspread_pandas import Spread
import dash_table
from ..app import app
app.css.append_css({'external_url': 'https://codepen.io/amyoshino/pen/jzXypZ.css'}) # noqa: E501
data = [
['Not Fulfilled','2019-02-12 6:23:00','6425386','1589625','jim.john@aol.com','Bank of America','Jim','John',"Jim's Place",'Collector'],
['Not Fulfilled','2019-02-12 6:45:00','6798541','1578542','ssmith@yahoo.com','US Bank','Steve','Smith',"Smith's Store",'Vision'],
['Not Fulfilled','2019-02-12 8:16:00','6673825','1384408','thelastresort@msn.com','Chase','Sarah','Sica','The Last Resort','Firewall'],
['Not Fulfilled','2019-02-12 9:01:00','4435827','1756843','aaa@gmail.com','Wells Fargo','Eric','Williams','AAA','Firewall']
]
fulfillment = pd.DataFrame(data,columns=['Status', 'Created At', 'Internal ID', 'Invoice #', 'Customer Email', 'Processing Bank', 'First Name', 'Last Name', 'Company Name', 'Fulfillment Type'])
layout = html.Div([
html.Div([
dash_table.DataTable(
id='datatable-interactivity',
columns=[
{"name": i, "id": i} for i in fulfillment.columns
],
data=fulfillment.to_dict("rows"),
editable=False,
sorting=True,
sorting_type="single",
row_selectable="single",
selected_rows=[],
style_table={'margin-top': 10, 'overflowX': 'scroll'},
style_cell={'text-align': 'center'}
),
], className='ten columns offset-by-one'),
html.Div(id='display_selected_row', className='eight columns offset-by-two')
])
@app.callback(
Output('display_selected_row', "children"),
[Input('datatable-interactivity', "derived_virtual_data"),
Input('datatable-interactivity', "derived_virtual_selected_rows")])
def update_graph(rows, derived_virtual_selected_rows):
if derived_virtual_selected_rows is None:
derived_virtual_selected_rows = []
if rows is None:
dff = fulfillment
else:
dff = pd.DataFrame(rows)
return html.Div([
print(derived_virtual_selected_rows[0]),
dash_table.DataTable(
id='display_selected_row',
columns=[
{"name": i, "id": i} for i in dff.columns
],
data=dff.iloc[[derived_virtual_selected_rows[0]]].to_dict("rows"),
editable=False,
style_table={'margin-top': 10, 'overflowX': 'scroll'},
style_cell={'text-align': 'center'}
),
])