I am on the verge of giving up on Dash totally since I struggle so much to implement basic add row/delete row/update row(table) and to get database updated automatically. I don’t know why is it so difficult to this basic thing. My table is editable and on click or enter value in a cell it is updating DB automatically, also I need to delete row and update it. I am using Python/Postgres DB.
Is there any basic example on how to do this or does anyone here have a basic working example? The documentation Editable DataTable | Dash for Python Documentation | Plotly of adding new rows/columns etc isn’t complete, I don’t see how to figure out what value user inserted into cells. Any help is appreciated.
You need to provide a minimum example of code that is not working for you but you expect it to be. There could be dozens of things that do not work in the way you expect them to work, provide any error you are getting or expected behavior vs. actual behavior. It’s impossible to guess what your problem is :).
Also it’s worth noting the DataTable is currently in Alpha, make sure you have the latest version installed as bugs are being constantly fixed.
I have two events that happen when user arrives at the app. The first event is ‘Add New Row’ (button) click event which should insert new data into a database when user starts typing into a Datatable cells in a newly added row.
The second event is update table which should update database if user starts typing anywhere except on a newly added row. I can’t distinguish between the two, between the newly added row that should do insert on typing and all other rows which should do update on user typing. I tried with n_clicks and everything I could think of but nothing works.
I created a ‘delete selected rows’ link which should remove rows from the Datatable and from the database also. That doesn’t seem to be possible at all or I couldn’t find how to do it, no ideas for that at all.
It is almost 7pm here and if I go and change code now it would take me at least an hour because I am not allowed to share the original code and I have a deadline tomorrow. If you know what I could do in a few sentences or a link that I could look at, that would be great.
what i meant by that is to keep using dash datatable in the frontend and find a more reliable way to update the table other than pd to sql. in this case, it is necessary to keep track of the changes to know which data to update, create or/and delete.