ktoole
01-28-2010, 11:50 AM
I wanted to have the field in error display in red and have the error show by the field, like you did in the customer master example. I put in the code for that and passed the values from the RPG for FLD and MSG, but it keeps telling me that "f" is not defined. What am I missing?
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 {
f=Ext.getCmp(data.FLD);
f.markInvalid(data.MSG);
f.focus();
// Ext.Msg.alert('Error',data.MSG);
};
Ext.getBody().unmask();
};
},
richard.milone
01-28-2010, 11:54 AM
Can you post up the full JSON response data from Firebug that is returned when you should be seeing an error message?
ktoole
01-28-2010, 12:53 PM
Here is what is the response field set:
{"SUCCESS":"0","FLD":"add_BNFARNNO","MSG":"Farm # may not be blank and must be a valid farm."}
Error message:
f is undefined
{removed local info}vvcall.pgm?opt=1023&pgm=vvinit&sid=F6C5A9420113535B9C12D7973DE4B147F4FDB0BF9000F5 75841A1535C68B93E1
Line 264
sean.lanktree
01-28-2010, 12:59 PM
Can you post the code where add_BNFARNNO is defined in your javascript?
ktoole
01-29-2010, 01:54 PM
var addWindow = new Ext.Window({
id: 'addWindow',
title: '<div align="center">Add Record</div>',
modal: true,
iconCls: 'add',
width: 1050,
autoHeight: true,
closeAction: 'hide',
autoScroll: true,
buttonAlign: 'center',
closable: false,
listeners:{
beforeshow:function(){
Ext.getBody().mask('<B>Retrieving default values...</B>', 'x-msg-loading');
Ext.Ajax.request({
url: 'vvcall.pgm',
params: {
action: 'getFieldDefaults',
pgm: 'MLPMABN2'
},
success: function(response){
var check = response.responseText;
if (check){
var data = Ext.util.JSON.decode(response.responseText);
if (data.SUCCESS == '1'){
Ext.getCmp('add_BNCMP').setValue(data.BNCMP);
Ext.getCmp('add_BNLOC').setValue(data.BNLOC);
Ext.getCmp('add_BNFARMNO').setValue(null);
Ext.getCmp('add_BNBARNID').setValue(data.BNBARNID) ;
Ext.getCmp('add_BNLENGTH').setValue(data.BNLENGTH) ;
Ext.getCmp('add_BNWIDTH').setValue(data.BNWIDTH);
Ext.getCmp('add_BNDED').setValue(data.BNDED);
Ext.getCmp('add_BNFLOR').setValue(data.BNFLOR);
Ext.getCmp('add_BNPIT').setValue(data.BNPIT);
Ext.getCmp('add_BNBED').setValue(data.BNBED);
Ext.getCmp('add_BNLITE').setValue(data.BNLITE);
Ext.getCmp('add_BNVENT').setValue(data.BNVENT);
Ext.getCmp('add_BNDENS').setValue(data.BNDENS);
Ext.getCmp('add_BNBLDG').setValue(data.BNBLDG);
Ext.getCmp('add_BNCEIL').setValue(data.BNCEIL);
Ext.getCmp('add_BNELEC').setValue(data.BNELEC);
// Ext.getCmp('add_Elec').setValue(false);
Ext.getCmp('add_BNHEAT').setValue(data.BNHEAT);
Ext.getCmp('add_BNCURTAINS').setValue(data.BNCURTA INS);
// Ext.getCmp('add_Curtains').setValue(false);
Ext.getCmp('add_BNLIGHTT').setValue(data.BNLIGHTT) ;
Ext.getCmp('add_BNPERP').setValue(data.BNPERP);
Ext.getCmp('add_BNMRTP').setValue(data.BNMRTP);
Ext.getCmp('add_BNSTAGES').setValue(data.BNSTAGES) ;
Ext.getCmp('add_BNHEADCAP').setValue(data.BNHEADCA P);
Ext.getCmp('add_BNGPSLONG').setValue(data.BNGPSLON G);
Ext.getCmp('add_BNGPSLAT').setValue(data.BNGPSLAT) ;
} else{
Ext.Msg.alert('Failure','Failed to receive default values from server');
};
}
Ext.getBody().unmask();
},
failure: function(){
Ext.getBody().unmask();
Ext.Msg.alert('Failure','Failed to receive a response from server');
}
});
}
},
buttons: [
{text:'Save',iconCls:'save',handler:function(){fnA ddRecord(true);}},
{text:'Cancel',iconCls:'cancel',handler:function() {
Ext.getCmp('addWindow').hide();
}}
],
items:[{
xtype: 'form',
layout:'column',
frame: true,
labelWidth: 100,
labelAlign: 'right',
defaults: {columnWidth: 0.3, layout: 'form'},
items:[{
defaults:{xtype:'fieldset', layout:'form', anchor:'100%', autoHeight:true},
// Field 1 - Company
items:[{
xtype:'combo',
id: 'add_BNCMP',
autoLoad: true,
triggerAction:'all',
forceSelection:true,
displayField:'TACNAM',
valueField:'TACOMP',
store: compStore,
fieldLabel:'Company No.',
editable: false,
listeners:{
select:{ fn:function(){
Ext.getCmp('add_BNFARMNO').clearValue();
Ext.getCmp('add_BNFARMNO').getStore().reload();
Ext.getCmp('add_BNFARMNO').reset();
Ext.getCmp('add_BNLOC').clearValue();
Ext.getCmp('add_BNLOC').getStore().reload();
Ext.getCmp('add_BNLOC').reset();
}}
}
},{
// Field 2 - Location
xtype:'combo',
id: 'add_BNLOC',
autoLoad: true,
triggerAction:'all',
forceSelection:true,
displayField:'IANAME',
valueField:'IALOC',
fieldLabel: 'Location',
mode: 'remote',
emptyText:'Select a Location...',
listeners:{
select:{ fn:function(){
Ext.getCmp('add_BNFARMNO').clearValue();
Ext.getCmp('add_BNFARMNO').getStore().reload();
Ext.getCmp('add_BNFARMNO').reset();
}}
},
store: new Ext.data.JsonStore({
autoLoad:true,
url:'vvcall.pgm',
root:'VINLOC',
fields:['IALOC','IANAME'],
listeners:{
beforeload:{
fn: function(){
this.baseParams={
pgm:'MLPMABN2',
action:'getLocation',
comp: Ext.getCmp('add_BNCMP').getValue()
}
}
}
}
}),
editable: false
},{
// Field 3 - Farm Number
xtype:'combo',
id: 'add_BNFARMNO',
autoLoad: false,
triggerAction:'all',
forceSelection:true,
displayField:'FMNAME',
valueField:'FMFARMNO',
fieldLabel: 'Farm No.',
emptyText:'Select a Farm...',
store: new Ext.data.JsonStore({
autoLoad:false,
url:'vvcall.pgm',
root:'MLPFARM',
fields:['FMFARMNO','FMNAME'],
listeners:{
beforeload:{
fn: function(){
this.baseParams={
pgm:'MLPMABN2',
action:'getFarms',
comp: Ext.getCmp('add_BNCMP').getValue(),
loc: Ext.getCmp('add_BNLOC').getValue()
}
}
}
}
}),
editable: false
},{
sean.lanktree
01-29-2010, 02:18 PM
Looks like you have a typo in your code. The JSON response calls the field "add_BNFARNNO". However, in the JavaScript, it is defined as "add_BNFARMNO".
ktoole
02-01-2010, 10:41 AM
Thanks...that worked. I missed the typo.
vBulletin® v3.7.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.