Table does not update on "Create"
Table does not update on "Create"
kooliebwoy
Posts: 7Questions: 3Answers: 0
in Editor
Edit works perfectly. Updates automatically. I can also see the JSON response for when editing. Create also works, problem is I have to refresh the page to see the new row that was added. Yes I am displaying a primary key row that is auto increment in the back end. I am not allow them to enter value for that. I hide the field when the create form comes up. What am I doing wrong for the page not be refreshing?
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Does the create response look similar to this?
https://editor.datatables.net/manual/server#Create
If it looks correct then a link to your code from troubleshooting would be best.
Kevin
Below is the code that I use to display the data from the table and update the data using Editor. It works perfectly except for when creating a new one. It creates the new one but it doesn't refreshes the table and show automatically. You have to refresh the entire page to do that. Sorry am just getting back to this.
Model.php
view.php
Is
id
an auto incrementing column in the database?What is the JSON that is being returned by the server when the create request is sent? It would be useful to also see the parameters that are being sent.
I don't immediately see anything wrong with the code above I'm afraid.
Allan
Hi Allan,
Yes the "id" field is auto increment in the database. That is why I hide it from the editable form so a value cannot be entered.
On create this is what it returns. Screenshot attached.
Code used to get back the response
I missed the
field().hide()
call - sorry. I would suggest that you just don't include that fields in Editor at all!Thanks for the screenshots. The reason the row isn't appearing on the client-side is that the server isn't returning it. The information about the row should be in the
data
array - but your screenshots show that to be empty.Try removing
and
Allan
I guess I will just have to do that. Without the id field it works just perfectly. Sucks that you can't use that. That would be a great feature. Thanks for the help @Allan.
Do you just want to display the id in your DataTable? If so add:
into your PHP, and just don't include it in the Editor
fields
array.Allan