CRUD operations with flask
CRUD operations with flask
I am trying to setup the datatables CRUD operations with FLASK. And I have to admit that i am not a highly skilled programmer. I have got to a point where I can post the data to the backend and update the database. However I am unable to find the method for updating the table back after editing.
Is there an over-ride function for the EDIT button handler? I do send back the JSON of the updated row but the table does not update. I searched the examples but there is little by way of Pyhon flask. Again the issue is with the response.
I am evaluating the various options and would appreciate any guidance on the issue.
Answers
One thing to mention is that the It datatable WILL update if I reload using the refresh button of the browser. I am using AJAX. The problem is with AJAX response.
You need to send back JSON in the format that Editor expects - this is detailed in the client / server communication documentation for Editor.
I'm afraid I have no experience with Flask myself, so I can't help much in that regard, but any questions you might have about the client / server protocol, just let me know.
Regards,
Allan
Alan thanks for the post.
I am using the following structure below. Small excerpt from the code. Question is where do I insert a function of post submit to intercept the data sent back from the server.
The table is sending the correct json and I cn update my database but I am unable to update the row being edited.
Use the
postSubmit
event.Allan
Allan,
Thanks so I am able to use the post Submit program. And I am also able to add my own fields from the server and parse them.
Couple of issues I have not been able to resolve:
1. Can I send a different format of data than the application/x-www-form-urlencoded? I tried using "application/json" but it does not work.
2. Can we specify the url with the row_id? So that at the server I know which row to edit?
Yes, use
preSubmit
.Yes, use
ajax
as an object and specify the options you want. It is exactly the same as the jQuery$.ajax
object.Yes, you can use
_id_
in the URL string Editor will replace it with the id. Seeajax
for that as well.The other option is to use
ajax
as a function so you can make your own Ajax call.Allan