Hi all,
Excited to see the tables be officially released. It’s been a pain in the butt updating my code though.
Right now there are only two layouts:
- The home page is a list of links that go to URLs to define a filter on a data table
- The program page displays the table based on the URL
The main layout is:
app.layout = html.Div([
dcc.Location(id=‘url’, refresh=False),
html.Div(id=‘page-content’)
])
The callback is:
@app.callback(dash.dependencies.Output('page-content', 'children'),
[dash.dependencies.Input('url', 'pathname')])
def display_page(pathname):
print("pathname is")
print(pathname)
if pathname is not None:
program = pathname[1:]
print("program is")
print(program)
if pathname=='' or pathname=='/' or pathname is None:
print("returning home page")
return program_list_layout
else:
print("returning program page")
return program_layout(program)
The function “program_list_layout” returns fine. that works.
The function program_layout(program) is what I’m having trouble with. It SHOULD return some buttons and a table. Here’s the function:
def program_layout(program):
rows,columns = updateRowsforDash(program)
return [
html.Button('Submit', id='button',n_clicks=0,n_clicks_timestamp =0),
html.Button('Refresh', id='button2',n_clicks_timestamp =0),
html.Button('Add Row', id='addrow',n_clicks_timestamp =0),
html.Button('Test Button', id='button3',n_clicks_timestamp =0),
dt.DataTable(
columns=columns,
data = rows,
id='datatable')
]
Things that confuse me:
- The function runs but displays nothing
- There are no errors in the debugger
- If I remove the dt.DataTable component the buttons display fine
- If I make it a single-page app it runs fine. Only when I make it a multi-page app does this happen
What do? Thanks in advance. Sorry I’m a self-taught programmer, feel free to berate me.