Do I have to call draw in postSubmit?
Do I have to call draw in postSubmit?
LordTonix
Posts: 5Questions: 2Answers: 0
My REST API does not return data in the way DT wants it. So I had to edit the data in postSubmit. Do I have to call draw after that? This is not in the docs for postSubmit even though the docs explicitly mention modifying data recieved back from the response.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @LordTonix ,
This earlier thread here should help you - it's discussing the same issue.
Cheers,
Colin
@colin
I changed my table to use a submitComplete, and my UI will still not update without an explicit call to draw. This is what I am doing:
Hi,
The
postSubmit
event is actually the correct place to perform any manipulation on the data returned from the server before Editor processes it.As long as the data is in the correct format that Editor expects (which it looks like it probably will be from your second post), then there shouldn't be any need to call
draw()
as Editor will do that itself once it has updated any rows that were edited.From your original post, were you just seeking confirmation of that, or is there actually a problem with it?
Regards,
Allan
@allan There is actually a problem. Without table.draw() the new row never appears in my table. If I perform any searching, sorting, filtering, paging, or deleting (operations that seem to trigger a draw) then the new row will appear.
I am using the following supporting libraries:
My code is identical to above except I changed submitComplete to postSubmit. I tried to build out a Plunkr but since DataTables editor must be downloaded locally, it would not allow me to upload such large files.
That suggests that the JSON data modification is getting back to Editor and looking again at the data above I see why. The original
json
object isn't being modified - rather the local variablejson
is.This should do the trick:
Note how now the
json
variable isn't changed, but rather its properties are. That should allow it to work correctly (assuming that the data loaded from the server is a JSON data structure that matches that used by the row in the table).Allan