Displaying a notice after successful saving

Displaying a notice after successful saving

pisislerpisisler Posts: 91Questions: 19Answers: 1

Original discussion: https://datatables.net/forums/discussion/71557

I think the Editor should process an advanced result set allowing it to save fields with a notice.

Right now, Editor saves the form only when it receives an explicit true from server side. And if it receives anything else, it considers that the returned result is an error message.

I think it can return true with a message which is not necessarily an error. Think of this kind of use cases;

"Price is saved, now you should consider printing the new price label"
"You saved an international phone number, you better check if PBX would allow calling it"
"Your appointment is saved. Please don't forget to bring your test results as it is not present in your patient log".

Right now, Editor expects return true; or return $error; from the server. It could be something like this instead;

return [true, 'You are eligible for the gift box! Check your inbox to see how you can receive it.'];

A note: In the original discussion, I proposed that it could also be field based but maybe it is not in harmony with the base logic of a crud table. Like for example when you have an error in salary field, it doesn't matter if you have typed a valid value into the name field; it can (and maybe should) discard all of it telling you to correct the error first. Guess there is no point in saving one field while giving an error for another field. I firstly proposed this because my use case is a bit extraordinary where it required integrating a Datatables field into a third party service. So saving a valid field despite the other erroneous field would be useful in this kind of special cases which makes it less worthy to invest on. But nevertheless, displaying a notice after saving could be very useful.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 17,264Questions: 25Answers: 4,098
    edited February 12 Answer ✓

    Not sure I understand the problem description so my answer may not apply but maybe you can return extra data in the Editor's JSON response with the message to display. An event like submitSuccess could be used to extract the extra data from the JSON and display the message.

    Kevin

  • pisislerpisisler Posts: 91Questions: 19Answers: 1
    edited February 12

    You are absolutely right. You can display whatever you like with post submit events one of which is being submitSuccess; how could I overlook that.. I think I was too busy looking for a server-side method that I couldn't see it could be easily done on client-side although I am already using many events to take actions after submitting.

Sign In or Register to comment.