PDA

View Full Version : Form fields not populating after a successful form.load()



TampaBay55
31 Dec 2010, 8:00 AM
Greetings:

I can't, for the life of me, figure out what I am doing wrong here. Clicking on the "load" button pulls the correct JSON formatted data but the data will not populate on the form. Can anyone see what I am missing here, please? Thanks!


Ext.ns('LSIPay.forms');

LSIPay.forms.payDataForm = Ext.extend(Ext.form.FormPanel,{
border : false,
labelAlign : 'right',
labelWidth : 104,
waitMsgTarget: true,
bodyStyle : 'background-color:transparent',
initComponent: function(){
var config = {};
Ext.apply(config,{
url : 'paydataprocess',
items: this.buildForm()
});
Ext.apply(this, Ext.apply(this.initialConfig, config));
LSIPay.forms.payDataForm.superclass.initComponent.apply(this, arguments);
},
buildForm : function(){
return [{
xtype : 'fieldset',
title : 'Payment Information',
autoHeight : true,
defaultType: 'textfield',
items :[{
xtype : 'datefield',
fieldLabel : 'Payment Date',
width : 100,
name : 'paydate',
allowBlank : false,
value : new Date()
},{
xtype : 'combo',
fieldLabel : 'Payment Source',
width : 100,
name : 'paysource',
triggerAction: 'all',
mode : 'local',
editable : false,
store : new Ext.data.SimpleStore({
fields: ['paySource'],
data : [['Patient'],['Insurance']]
}),
valueField : 'paySource',
displayField : 'paySource',
value : 'Patient'
},{
fieldLabel : 'Source Name',
name : 'sourcename',
width : 150,
allowBlank : false
},{
xtype : 'combo',
fieldLabel : 'Payment Method',
width : 100,
name : 'paymethod',
triggerAction: 'all',
mode : 'local',
editable : false,
store : new Ext.data.SimpleStore({
fields: ['payMethod'],
data : [['Check'],['Credit Card'],['Cash'],['Money Order'],['Other']]
}),
valueField : 'payMethod',
displayField : 'payMethod',
value : 'Check'
},{
fieldLabel : 'Document ID',
name : 'docid',
width : 150,
allowBlank : true
},{
xtype : 'numberfield',
fieldLabel : 'Payment Amount',
width : 100,
name : 'payamount',
allowBlank : false,
value : 0
}]
}]
}
});
Ext.reg('paydataupdateform',LSIPay.forms.payDataForm);

LSIPay.forms.payDataWin = Ext.extend(Ext.Window,{
recordAction : null,
recordID : null,
initComponent : function(){
var config = {};
Ext.apply(config,{
title : 'Payment Ledger Editor',
width : 310,
height : 274,
padding : 6,
floating : true,
shadow : true,
shadowOffset : 14,
modal : true,
layout : 'fit',
plain : true,
closable : false,
closeAction : 'hide',
items : [{id:'paydataform',xtype:'paydataupdateform'}],
buttons : this.buildButtons()
});
Ext.apply(this, Ext.apply(this.initialConfig, config));
LSIPay.forms.payDataWin.superclass.initComponent.apply(this, arguments);
},
buildButtons: function(){
return[
{
text : 'Load',
handler: function(){
Ext.getCmp('paydataform').getForm().load({params:{xaction:'fetch',recid:this.recordID,},waitMsg:'Retrieving...'});
},
scope : this
},{
text : 'Cancel',
handler: this.hide.createDelegate(this,[])
}
];
},
});
JSON formatted data:




{
"success": true,
"data": [
{
"recordid": "8c1ee73b-f666-11df-ace2-465f0d238a49",
"paydate": "11/22/2010",
"paysource": "Patient",
"sourcename": "Shawn Simmons",
"paymethod": "Check",
"docid": "12358",
"payamount": 100
}
]
}

skirtle
31 Dec 2010, 1:59 PM
You've wrapped your data in an array. I haven't tested it but from reading the docs it seems that isn't what it expects.

TampaBay55
1 Jan 2011, 5:44 AM
You've wrapped your data in an array. I haven't tested it but from reading the docs it seems that isn't what it expects.

Skirtle - you are absolutely correct. I was so focused on the code being broken that I didn't really pay much attention to the data. Lesson learned. Thanks much for your help and have a great New Year! Cheers!