How to disable editor updating the table after server response received?

How to disable editor updating the table after server response received?

swrobelswrobel Posts: 10Questions: 2Answers: 0

I have a special case where my server returns the json for the entire table upon editing a single row because the entire table needs to be redrawn. I don't want create to draw the new row, edit to draw the edited row, or delete to remove the row, I just want it to submit to the server, then I want to be able to trigger a redraw myself with the json. I realize I can "trick" datatables by doing the following

editor.on('postSubmit', (e, json, data, action) => json.data = [])
editor.on('submitSuccess', (e, json, data) => table.clear().rows.add(json).draw())

...but essentially editor is drawing an empty row on create/edit then my clear/rows.add() is taking place, which seems unnecessary. Is there some way to disable the post-postSubmit behavior?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,761Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Hi,

    Is there some way to disable the post-postSubmit behavior?

    I'm afraid not - that's fairly baked into Editor. What I would suggest is that you just return that single row (if possible) as normal and then in submitSuccess call ajax.reload():

    editor.on( 'submitSuccess', () => {
      table.ajax.reload();
    } );
    

    Regards,
    Allan

  • swrobelswrobel Posts: 10Questions: 2Answers: 0

    Ok, thanks. I was trying to avoid a second round-trip to the server, so I think I'll stick with my solution since it's working.

This discussion has been closed.