ktoole
02-22-2010, 11:09 AM
How can I get multiple field errors to display on the screen? I tried to send back Json data with FLD and MSG in multiple times and found it ignored all but the last one. I figured out it needs to be in an array for ExtJS to interpret it correctly. How do I get the FLD and MSG into an array? I keep getting the incorrect format when I send it using:
vvOut_toJsonPair(%trim(ErrorMessages));
The Json looks like this:
{"SUCCESS":"0","ERRORS":"[{FLD:add_BNFARMNO","MSG":"Farm # may not be blank and must be a valid farm.","FLD":"add_BNBARNID","MSG":"The Barn ID may not be blank.}]"}
This is missing the quotes on the first FLD and it's data and also puts a quote on the [ and the other ].
Below is the ExtJS code to display the errors. Do I need some kind of loop for multiple fields in error or will ExtJS just sense the array and know how to handle it.
success: function(response){
var check = response.responseText;
if (check) {
var data = Ext.util.JSON.decode(response.responseText);
if (data.SUCCESS == '1') {
Ext.getCmp('addWindow').hide();
parent.showMessage('','<center><b>Record Added</b></center>');
dsMainMLPMABN2Grid.reload();
} else {
if (data.FLD==null){Ext.Msg.alert('Error',data.MSG);}
else{
f=Ext.getCmp(data.FLD);
f.markInvalid(data.MSG);
f.focus();
}
};
Ext.getBody().unmask();
};
},
vvOut_toJsonPair(%trim(ErrorMessages));
The Json looks like this:
{"SUCCESS":"0","ERRORS":"[{FLD:add_BNFARMNO","MSG":"Farm # may not be blank and must be a valid farm.","FLD":"add_BNBARNID","MSG":"The Barn ID may not be blank.}]"}
This is missing the quotes on the first FLD and it's data and also puts a quote on the [ and the other ].
Below is the ExtJS code to display the errors. Do I need some kind of loop for multiple fields in error or will ExtJS just sense the array and know how to handle it.
success: function(response){
var check = response.responseText;
if (check) {
var data = Ext.util.JSON.decode(response.responseText);
if (data.SUCCESS == '1') {
Ext.getCmp('addWindow').hide();
parent.showMessage('','<center><b>Record Added</b></center>');
dsMainMLPMABN2Grid.reload();
} else {
if (data.FLD==null){Ext.Msg.alert('Error',data.MSG);}
else{
f=Ext.getCmp(data.FLD);
f.markInvalid(data.MSG);
f.focus();
}
};
Ext.getBody().unmask();
};
},