How to cancel row removal when editor remove button finishes it's work

How to cancel row removal when editor remove button finishes it's work

a.lerouxa.leroux Posts: 3Questions: 1Answers: 0

Hello,

Working with datatables 1.12.1 + Editor 2.0.8
One remove button configured and linked to the editor instance, itself linked to the datatable in the usual way.

I would like to cancel row deletion when the postSubmit event modifyes json payload to contain the error :
jso = { error: 'Editor, please cancel row removal because the process has failed somehow' }

The button extends 'remove' editor button.

How to achieve this in the most effective and simple way ?

This question has an accepted answers - jump to answer

Answers

  • a.lerouxa.leroux Posts: 3Questions: 1Answers: 0

    Please apologize typo.

    postSubmit button callback alters json parameter, not jso as written above. So

    json = { error : 'Editor, please cancel row deletion from datatable !'}

  • allanallan Posts: 62,522Questions: 1Answers: 10,272 Site admin
    Answer ✓

    Having the error parameter in the JSON response from the server should stop the row being removed client-side. If that isn't working for you, can you link to the page showing the issue so I can get the full picture of how DataTables and Editor are configured and debug it?

    Thanks,
    Allan

  • a.lerouxa.leroux Posts: 3Questions: 1Answers: 0

    You are correct. Bug due to the user, not the framework.

    the postSubmit requires the user to alter json parameter, not reassigning it to a new object like { error: 'whatever' }.

    Altering json object in-place does the trick : json.error = 'whatever is to be said on the U/I side';

    Thansk for your fast reply. that is great.

  • allanallan Posts: 62,522Questions: 1Answers: 10,272 Site admin

    That would do it. Good to hear you got it fixed :)

    Allan

Sign In or Register to comment.