Hey there!this is the look of my table. My Dash Code output
i want to print the NGID value of selected rows in python console. I have created callback function. But when i select the row it do nothings
This is the code for my layout:
def dasher():
df = pd.read_csv('wyjebany.csv')
df = df[~df.HOME.str.contains('Beach|Futsal')]
df = df[~df.COUNTRY.str.contains('Germany Oberliga NOFV|France Youth U19
League|Portugal Champions NACIONAL Juniores A 1|Spanish Bizkaia-Tercera')]
df = df.replace(to_replace='Division|League|Liga|Footbal|Primavera', value='',
regex=True)
# df = df.replace(to_replace='.', value='', regex=True)
print(df)
print(df.columns)
app.layout = dash_table.DataTable(
columns=[{"name": i, "id": i} for i in df.columns],
row_selectable='multi',
sort_action='native',
# editable=True,
row_deletable=True,
# rows=[{}],
selected_rows=[],
css=[{'selector': 'tr:hover',
'rule': 'background-color: #80FF80',
# 'font-family': 'Times New Roman',
}],
html.Div(id='hidden-div', style={'display': 'none'},
),
and here is the code for callbackfunction
@app.callback(
dash.dependencies.Output('hidden-div', 'style'),
[dash.dependencies.Input('table', 'columns'),
dash.dependencies.Input('table', 'selected_rows')])
def print_value(columns,selected_rows):
print("Hi i am triggered")
# for i in selected_rows:
# print(i)
selected_rows = [columns[i] for i in selected_rows]
# selected_rows = pd.DataFrame(rows).iloc[i]
print(selected_rows)
style = {'display': 'none'}
return style
Use derived_virtual_selected_rows
instead of selected_rows
.
It worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With