How to add a new datatable with back-end filtering?

I have built an app that uses dash datatables for exploring data. The tables have back end filtering, I have replaced the native filters with something more flexible (a filter cell can, for example, understand python code so that simple python-expressions can be applied on the column beneath it). This requires a callback function.

Here is the challenge: The user should be able to open a datafile in a new datatable. But this is not simple since the app can’t add a new callback function while it is running. How to solve this?

For now, I pre-create a stack of datatables+callbacks in the app code. When a user reads in data, the app takes a table from the stack. This solution sets a limit to the number of tables that the app can open and it makes the code complex compared to opening a datatable with native filtering which requires no callback.

Is it possible to create new back-end filtered datatables that share the same callback function?
Is there another way of solving the challenge?

On my wishlist:

  • datatables with native back-end filtering
  • programmable native filters

Check out pattern matching callbacks for general purpose “this callback is used over and over” - Pattern-Matching Callbacks | Dash for Python Documentation | Plotly

However, if you are creating callbacks dynamically and the dataframe isn’t available during runtime, then you won’t be able to pass that dataframe into the filtering callback in advance. This is sort of the classic “sharing data between callbacks” problem where you’ll need to store the data somewhere for the callback to access it later when it executed: Part 5. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly

In Dash 2.0, we’re introducing “All-in-One” components to make this easier. I’ve written a sample All-in-One DataTable that you an use here: All-in-One Components | Dash for Python Documentation | Plotly. This was published yesterday, so great timing :slight_smile: Would love for you to give it a try!

1 Like

A general way to go about this might be to use loop through the date fields and build the list!

1 Like