Closed geophpherie closed 11 months ago
Hello @jbeyer16 ,
I think this may be due to how you are setting the rowData with the store. In this fashion, it looks like you have actually linked them to be the same.
Try using JSON.parse(JSON.stringify(data)) as what you are returning to the rowData.
Also, I would highly recommend using rowTransactions vs resending the rowData back and forth each time. In order for rowTransactions to work, you'll need to have the getRowId set as a uniqueid from the data.
@BSd3v ooooooh great observation. thanks for pointing that out. indeed it seems they are referencing the same object, creating a copy as you suggest seems to now work as expected. Thanks for the second set of eyes there.
Indeed in my actual use case I have getRowId
set as it did appear as the better way to go about things!
I appreciate the help here!
You may have accidentally found a way to solve the issue for rowData
persistence. XD
Python 3.11.4, Dash 2.14.1, Dash-Ag-Grid 2.4.0
I'm posting here as I cannot seem to reproduce this behavior with a more or less equivalent set-up using dash-core-components so my initial thought is it might be related to ag-grid somehow.
The basic gist is this: I have a
dcc.Store
to handle my state and am pulling from it to update my grid'srowData
. In my current example, I'm using a callback (server side) attached tocellValueChanged
to update my state, then using the state to updaterowData
. [it's a bit circular for this trivial example, but in my actual use case I'm trying to draw/patch all my tables from a single source of truth in state where some computations might need to happen oncellValueChange
before sending new data to the tables]. I'm experimenting with the update torowData
happening as either a client side callback or a server side one. However, i've stumbled into a situation where it seems as though they behave differently and in an unexpected fashion.Now, please bear with me as it's a slightly weird scenario, but essentially, if I end up calling
PreventUpdate
from mycellValueChanged
callback, when myrowData
update callback is on the client, I still see updates to my state/localStorage (unexpected) whereas when it lives on the server, i do not (as expected).The reason I felt this was worth to create an issue is that, with the only route to update state/localStorage being blocked by a
PreventUpdate
, I found it strange that the existence of this clientside callback let the state/localStorage still update.Hopefully some code will help:
Here's a minimal example.
This first screen cap is the "unexpected" behavior using the clientside callback. You'll see how making changes in the table updates the Local Storage, as well as a separate clientside callback printing the storage values to a screen. However, when I enable
preventUpdate
, you'll see Local Storage still updates, however the clientside callback printing to screen doesn't. This just seems very odd to me, as 1) i expect that state should not be updated here and 2) since it is anyway, why is only one of the callbacks "seeing" it?https://github.com/plotly/dash-ag-grid/assets/19380579/846f3953-46b6-48c0-9a9a-cf03e9cf6245
This second screen cap is the "expected" behavior using the serverside callback - the state does not update when
preventUpdate
is in effect.https://github.com/plotly/dash-ag-grid/assets/19380579/f69a5249-a00a-4660-a7ae-90fbd2f114c9
Hopefully enough of that is ... somewhat clear?