Filter condition from URL or a table

Hello,

I am struggling with this interactive dashboard idea:

I have a page with two areas:

  • table with all items (left side)
  • table with item details (right side)

… and I would like to update the right table based on click on the item in the left table.
So far easy, using AG Grid on the left for getting the selected ID and using it in callback to update right side.

… but I also want to use the ID from URL (query string) to visit the page and to have the data filtered by this ID.
Additionally, clicking in the left table should update the URL (no page refresh, data on the right is already filtered by pandas in the background), so these are always synced.

So basically this logic:

input: url OR left table
output: right table.

How to implement this in an elegant fashion?

thanks!

Hello @q123,

Welcome to the community!

Do you want the grid selections on the left to override what the url has?

If so, you can do something like this:

def layout(**kwargs):
    if kwargs.get('yourID'):
         return # cater first selected option
    return # no selected option

@app.callback(
    Output('right', 'grid'),
    Input('left', 'selectedRows'),
    prevent_initial_call=True
)
def setRight(s):
    if s:
        return # set selected option

2 Likes

Thanks, that works - I need to work more on internalizing Dash principles. Documentation does not help much in this.
Which leads me to another related question (not covered in docs i believe).

Using layout as a function, what could be the arguments for this function? Only the query strings, or can potentially use some other and force the layout to refresh?

Thanks a lot and sorry for these newbie questions. Community support does so much when the documentation is sparse.

q

Hello @q123,

Check here:

It’s variable paths or query strings typically.

1 Like