Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Some Problem in Multi-Page Apps. #19

Closed

Description

@soloblack
app.layout = html.Div([
    dcc.Location(id='url'),
    html.Div(id='page-content'),
])

index_page = html.Div([
    dcc.Link('a', href='/HLIndex'),
    html.Br(),
    dcc.Link('b', href='/VolFundFace'),
])

@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    print pathname
    if pathname =='/':
        return index_page
    elif pathname == '/VolFundFace':
        return HL_View_VolFundFace.layout_
    elif pathname == '/HLIndex':
        return HL_View_HLIndex.layout
    else:
        return '404'
HL_View_VolFundFace.layout_ = html.Div([
    html.Div([
            html.Div([
                dcc.Dropdown(
                    id='xaxis-column',
                    options=[{'label': i, 'value': i} for i in available_indicators],
                    value=u'资金面'
                ),
            ],
            style={'width': '48%', 'display': 'inline-block'}),
            html.Div([
                dcc.Dropdown(
                    id='yaxis-column',
                    options=[{'label': i, 'value': i} for i in available_indicators],
                    value=u'波动率(20日)'
                ),
            ],style={'width': '48%', 'float': 'right', 'display': 'inline-block'})
        ]),
    dcc.Graph(id='indicator-graphic'),
    dt.DataTable(
        rows=table_data,
        columns=table_columns,
        row_selectable=True,
        filterable=True,
        sortable=True,
        selected_row_indices=[],
        id='datatable-gapminder'
    ),
    html.Div(id='selected-indexes'),
    ], className="container")

I have a Multi-Page Apps routing like this, and in this way the HL_View_VolFundFace.layout_ cannot be shown well.

But if i do like this

elif pathname == '/VolFundFace':
        app.layout = HL_View_VolFundFace.layout_

it can shown well

Activity

  1. chriddyp commented on Nov 24, 2017

    @chriddyp
    Member
  2. hscspring commented on Apr 24, 2018

    @hscspring

    I met the same issue..

    it works when i used single page, but doesn't when multi-pages...
    i used https://github.com/plotly/dash-table-experiments/blob/master/usage.py,
    and also with the solution you recommend, but still issues...

    i got a response of server, but the page show nothing....

    i get it, thanks very much for your code.
    it's really cool!


    Addtion:

    Remember to add html.Div(dt.DataTable(rows=[{}]), style={'display': 'none'} to your app.layout in run.py, for u to run your page correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions