I am using record.erase to delete a record, and I want to be able to display an error message if the backend is unable to delete the record for whatever reason. I want to be able to display the msg that is returned in the JSON. I assume I can do that through the operation parameter but haven't been able to find a way.
So how can I access the "success" and "msg" from the JSON?
Controller
if (record.data.privatePwdsCount === 0)
Ext.Msg.confirm("Delete", "Are you sure you want to delete this group?", function (id, value) {
if (id === 'yes') {
record.erase({
success: function (record, operation) {
// check if 'success' is true or false
// if true = do nothing
// if false = display error msg to user
}
});
}
});
else {
Ext.Msg.alert("Cannot Delete Group", "This group has existing passwords, delete the passwords first to continue");
}
JSON
"{"success":true,"msg":"Private Group 20 was deleted."}"