Issue with dash dataTables in cascaded if loops

Hello dear Dash friends,

I have a very long callback function (about 1500 lines :face_with_open_eyes_and_hand_over_mouth:).
First I open a database connection, I do a lot of calculations with the data from the database and display the results in cascaded if-loops.
Results are some indicators and a graph.

It used to work very well but since I started to use dash data table to display the indicators, I have some strange errors in some specific cases. I am trying to isolate the source of the error but with no success so far.
I wonder if it can be a bug from dash data tables.
The rationale behind using dash datable in my case is to have a customizable and compact way to display data.

This is how I used to display the indicators in the if loop:

                            html.H4(variable1),
                            html.P(text1),
                            html.H4(variable2),
                            html.P(text2),
                            html.H4(variable3),
                            html.P(text3),
                            html.H4(variable4),
                            html.P(text4),
                            html.H4(variable5),
                            html.P(text5),
                            html.H4(variable6),
                            html.P(text6),
                            html.H4(f"{variable7}/{variable8}"),
                            html.P(text7),

This is how I do it know with the dash data tables:

First, before the if loops, creating the data frame I will use to fill the dash data tables

    d1 = {"text": [variable1]}
    df1 = pd.DataFrame(data=d1)

    d2 = {"some text here": [variable1], "some text here": [variable2]}
    df2 = pd.DataFrame(data=d2)

    d3 = {"some text here": [variable1],
            "some text here": [variable3],
            '''some text here''': [variable4],
            }
    df3 = pd.DataFrame(data=d3)

    d4 = {"some text here": [variable1], "some text here": [variable2],
            "some text here": [variable3],
            '''some text here''': [variable4],
            }
    df4 = pd.DataFrame(data=d4)

    d5 = {"some text here": [variable1, "", "",
            "some text here", variable5],
           "some text here": [variable2, "", "",
           "some text here",
            variable6],
            ''some text here'': [variable3, "", "",
            "some text here", variable7],
            "": [ "", "", "", "some text here", variable8],
            }
    df5 = pd.DataFrame(data=d5)

    d6 = {"some text here": [variable1, "", "",
            "some text here", variable5],
            "some text here": [variable2, "", "",
            "some text here",
            variable6],
            "some text here": [variable3, "", "",
            "some text here", variable7],
            ''some text here'': [variable4, "", "",
            "some text here", variable8],
            }
    df6 = pd.DataFrame(data=d6)

And then in the if loops, creating the corresponding dash data table, for example for the data frame 1:

                            dash_table.DataTable(
                                id='table', data=df1.to_dict('records'),
                                columns=[{"name": j, "id": j} for j in df1.columns],
                                style_as_list_view=True,
                                style_cell={
                                    'backgroundColor': 'white',
                                    'whiteSpace': 'normal',
                                    'height': 'auto',
                                    'width': 'auto',
                                    # 'lineHeight': '15px',
                                    'font-family': 'lora',
                                    'font-size': '95%',
                                    'padding': '15px',
                                    'textAlign': 'center',
                                    'border': '1px solid white'
                                },
                                # style_data_conditional=[
                                #     {
                                #     'if': {
                                #         'row_index': 0,
                                #         'column_id': "Débit 'ICOS' (m3/H)",
                                #         },
                                #     'backgroundColor': 'green',
                                #     'color': 'white'
                                #     },
                                #]
                            ),

This issue seems to be only for data frame 5 and data frame 6. In the data used for the data frames, I tried replacing the empty texts “” by some random text “allo” and replacing all texts by variables but the issue persists.

Here is the error I have now:

But sometimes the error below also appears (that looks like this one Pattern-Matching Callbacks doesn't work for dash-table):

ANY HELP?

Hi @davi

Is the line above a typo? If i changed it to double quotes, the tables 5 and 6 shows up

 "some text here": [variable3, "", "",
1 Like

Hi @AnnMarieW thanks a lot for your feedback!
Yes, it is a typo but I fixed it and the issue remains. I will do my best to share a minimum reproducible example soon :slight_smile: