PDA

View Full Version : customizing a success message



dlstrawn
22 Apr 2010, 12:19 PM
I have the following function:


function fnEmailAnAlert(){
Ext.getBody().mask('<B>Sending Email...</B>', 'x-msg-loading');
var selectedRows = Ext.getCmp('mainDPA0006RGrid').getSelectionModel().getSelections();
for(var i = 0, len = selectedRows.length; i < len; i++){
Ext.Ajax.request({
url: 'vvcall.pgm',
params: {
action: 'emailRecord',
pgm: 'DPA0006R',
AF01ETAD:Ext.util.Format.date(selectedRows[i].data.AF01ETAD,'Ymd'),
AF01RNO:selectedRows[i].data.AF01RNO,
AF01CNO:selectedRows[i].data.AF01CNO,
AF01INO:selectedRows[i].data.AF01INO,
},
success: function(response){
var check = response.responseText;
if (check) {
var data = Ext.util.JSON.decode(response.responseText);
if (data.SUCCESS == '1') {
parent.showMessage('','<b><center>Email for Container ' + ????data.AF01CNO???? + ' Sent Successfully</b></center>');
//dsMainDPA0006RGrid.reload();
} //else {
//Ext.getCmp(data.FLD).markInvalid(data.MSG);
//Ext.getCmp(data.FLD).focus();
//}
}
},
failure: function(){
Ext.getBody().unmask();
Ext.Msg.alert('Failure','Failed to receive a response from server');
}
})
}
Ext.getCmp('mainDPA0006RGrid').getSelectionModel().clearSelections();
//selections = Ext.getCmp('mainDPA0006RGrid').getSelectionModel();
//selections.clearSelections();
Ext.getBody().unmask();
}
What do I put in the red section above to get the container # (AF01CNO) to show in the success message window that pops up?

I tried using the selectedRows array, but it said it was undefined.

CrazyEnigma
23 Apr 2010, 7:06 AM
You missed a parameter in your success function called options, and that is where you may obtain the params you sent to the server.

dlstrawn
28 Apr 2010, 8:29 AM
Sorry about the dup post.

Could you give me an example. I am having a hard time nailing it down. Thanks.

cnelissen
28 Apr 2010, 10:31 AM
Something like this is what I use:



new Ext.data.Connection().request({
url: '/some/backend/script.php',
method: 'POST',
params: {'param1': 'value1'},
success: function(response) {
var response = Ext.decode(response.responseText);
if (response.success == false) {
Ext.Msg.alert('Error', response.message);
} else {
Ext.Msg.alert('Success', response.message);
}
},
failure: function(response) {
Ext.Msg.alert('Error', 'Server Failure: ' + response.status);
}
});


The response from the action should be something like:



{success: true, message: 'Save Successful'}


or



{success: false, message: 'Save Failed'}

dlstrawn
30 Apr 2010, 6:18 AM
Thanks for the help!