Previous data and data attributes are identical after changes made

Hey,

Whenever i copy-paste multiple values from within the datatable, the data_previous attribute shows the current data, not the previous data.

This behaviour is preventing updates to the database whenever someone copies multiple cells and pastes them in the table.

I didnt write much code so there’s no place for errors from my end, I just looked at the inputs of the previous data and current data and saw they are exactly the same.

Has anyone got any idea whats happening ?
Any suggestions how to fix this ?

p.s I use a django framework.

2 Likes

I’m having exactly the same problem. Have you had any luck fixing this?

1 Like

Same probleme here ! It makes this clientside_callback useless to find which cell has been changed

app.clientside_callback(
    """
    function (input, old_input) {
        if(JSON.stringify(input) != JSON.stringify(old_input)) {
            for (i in Object.keys(input)) {
                newArray = Object.values(input[i])
                oldArray = Object.values(old_input[i])
                if (JSON.stringify(newArray) != JSON.stringify(oldArray)) {
                    entNew = Object.entries(input[i])
                    entOld = Object.entries(old_input[i])
                    for (const j in entNew) {
                        if (entNew[j][1] != entOld[j][1]) {
                            changeRef = [i, entNew[j][0], entNew[j][1]] 
                            break        
                        }
                    }
                }
            }
        }
        return changeRef
    }    
    """,
    Output("my-table-cell-changed", "data"),
    [Input("my-table", "data")],
    [State("my-table", "data_previous")],
)

Event with single value the copy & paste behavior still the same.

Refer to the bug issue here [BUG] Pasting into a DataTable overwrites `data_previous` with new data · Issue #2326 · plotly/dash · GitHub

In the case of when you need data and previous_data for detecting changed rows a server side dataset as previous data is a solution dash_table.DataTable - Determining which rows have changed - #7 by kvdm.dev