defineAction for Error - missing message


#1

If the user tries to insert a record into a grid that violates a MySQL back end unique key, I want to show a reasonable error message and delete the row from the grid. I defined:
dpg.defineAction(‘error’,function(xmlresponse){
var msg=xmlresponse.getAttribute(‘message’);
alert(msg);
return true;
}
Problems:

  1. Message is null and tells me nothing.
    The xml returned from data processor using php grid connector is:
    action type=“error” sid=“1552857346323” tid=“1552857346323”
    which is not helpful as it doesn’t tell me the error was a duplicate.
    How can I tell the cause of the insert failure for a decent error message?
  2. The defective row is not deleted. Is there a return value or default action that deletes the failed insert from the grid? Do it manually with the sid or tid I guess?
  3. I may need to go to smart rendering or dynamic loading so I don’t want to verify before sending that record is unique if possible.

#2

defineAction method allows only to detect the occurred error. You need to classify and specify a custom status on your server-side.


#3

Added a onDBError handler. That should do it. The mysql error message has the word ‘duplicate’ in it and ‘insert’.