Question about process of server data
Question about process of server data
yu yen kan
Posts: 65Questions: 31Answers: 0
I am using editor with ajax that return json data
{"error":null,"data":{"0":{"item":"1"}},"fieldErrors":[],"cancelled":[]}
after it edited, the datatable is not update the item value,
do I need to create a event for after submit to update and refresh the table data myself?
This discussion has been closed.
Replies
The problem might be that you are returning error and cancel objects in addition to the data. It could be the Editor is interpreting these as errors, even though they are blank, and not updating the table.
Is
item
the only field in the row? I believe you need to return the full row.Details are outlined here:
https://editor.datatables.net/manual/server
Kevin
I think Kevin is spot on here. Your
data
parameter should be an array of objects, not an object of objects.Allan
full row? even that data is just readonly?
That is correct. The server needs to respond with the full data for the row, as the manual page Kevin linked to states.
Allan
this is my table
this is data from ajax
this is response from edit
When I edit row, the row will gone, is that because of "className": 'details-control' column problem? if so, how can I do it?
Looks like you set the
rowId
in the table toid
. Did you set theidSrc
toid
in the Editor config?https://editor.datatables.net/reference/option/idSrc
Kevin
yes I did set it also for editor
Is the ajax data?
The row you edited?
If so the IDs are different.
Do you get any console messages on the browser?
Kevin
Yes - what Kevin says. And in addition to that:
Its almost right, but not quite.
data
should be an array.Allan
If I update it with this
the row remain, but unchanged
or this
the row is missing again
What Allan meant was that your return should be in an array
[]
. It should look like your data in the initial ajax response, for example:Its an array with one element.
Kevin
yes, finally it works, thanks a lot