Table does not update itself after 'insert', 'update' or 'delete' entry using editors buttons
Table does not update itself after 'insert', 'update' or 'delete' entry using editors buttons
So the problem is what the header says - "Table does not update itself after 'insert', 'update' or 'delete' entry using editor's buttons". My datatables and their editors use java spring boot backend and request data via ajax. But after I add, edit or delete an entry - the changes only affect DB and data in table remain the same and I have to refresh the page manually.
Here is the github link so you could watch it yourself and help me with resolving the problem
Thanks in advance!
Answers
Does your server script follow the Editor Client / Server protocol, shown here?
Kevin
Yes seems like my server script follows the protocol!
Use the browser's network inspector tool to verify the responses from the server. Let us know if it looks correct. Maybe post a sample response or two so we can take a look.
Kevin
...
According to the docs I posted the response should look similar to this:
Note the data is in the
data
object and the row or rows are in an array.Kevin
Kevin. it is not necessery to have "data" there since I configured dadaSrc option on ajax. Did you watch my project on girhub at all?
No I didn't use
mvn install
or other steps to install the app on my machine.@allan or @colin can comment on this but the
ajax.dataSrc
is for Datatables not Editor. The Editor is the one looking for the data. The Server to Client docs state that the Editor expects a JSON response withdata
and other objects in the response. I'm not familiar with any options to change this. I may be wrong thoughKevin
I haven't had a chance to install the app yet, but yes, Editor will expect data to be returned in the format defined here and that is not effected by
ajax.dataSrc
in DataTables.From your
dataSrc
option you are returning an array of data only. The problem with that in Editor is that it doesn't allow error information to be returned from the server - e.g. theerror
orfieldErrors
properties can't be defined since it is an array, not a JSON object.As such, I'd strongly encourage you to change the response from the server.
That said, if that isn't possible, you could use a bit of a hack like this:
We need to modify the
json
parameter that is passed since that is what Editor will have to work with (we can't return a different value). So this addes adata
property onto it with a clone of the array.Its a hack, and I don't recommend it - as I said above, return an object to be able to send error information back. But that should work if push comes to shove!
Allan
Thanks you all guys! You helped me!