PDA

View Full Version : formpanel field values



beefwellington
4 May 2011, 12:30 PM
So based on the KitchenSink demo, I have the following code:



Ext.regModel('Calculator', {
fields: [
{name: 'roll_diameter', type: 'float'},
{name: 'core_diameter', type: 'float'},
{name: 'web_thickness', type: 'float'},
{name: 'web_length', type: 'float'},
]
});

var frmUtilityCalculator = new Ext.form.FormPanel({
//scroll: 'vertical',
//url : 'postUser.php',
standardSubmit : false,
items: [{
xtype: 'fieldset',
id: 'myFieldSet',
title: 'Web Roll Length',
instructions: 'Enter any <b>3</b> of the above to calculate the remaining field.',
defaults: {
required: false,
labelAlign: 'left',
labelWidth: '40%'
},
items: [
{
xtype: 'numberfield',
id: 'nfldRoll_diameter',
name : 'nfldRoll_diameter',
label: 'Roll Diameter',
useClearIcon: true,
autoCapitalize : false
}, {
xtype: 'numberfield',
name : 'core_diameter',
label: 'Core Diameter',
useClearIcon: true,
autoCapitalize : false
}, {
xtype: 'numberfield',
name : 'web_thickness',
label: 'Web Thickness',
useClearIcon: true,
autoCapitalize : false
}, {
xtype: 'numberfield',
name : 'web_length',
label: 'Length of Web',
useClearIcon: true,
autoCapitalize : false
}]
}],
listeners : {
submit : function(frmUtilityCalculator, result){
console.log('success', Ext.toArray(arguments));
calculateWebRollLength();
},
exception : function(frmUtilityCalculator, result){
console.log('failure', Ext.toArray(arguments));
}
},

dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
ui: 'light',
items: [
{
text: 'Reset',
handler: function() {
frmUtilityCalculator.reset();
}
},
{xtype: 'spacer'},
{
id: 'btnCalculate',
text: 'Calculate',
ui: 'confirm',
cls: 'btnUtility',
handler: function() {
calculateWebRollLength(frmUtilityCalculator.form.findField('nfldRoll_diameter').getValue());
}
}
]
}]
});


function calculateWebRollLength(roll_diam){
alert('roll_diam: ' + roll_diam);
}

When I try click "Calculate" to get the value of "nfldRoll_Diameter", I get the error

"Uncaught TypeError: Cannot call method 'findField' of undefined" which points to this line:



calculateWebRollLength(frmUtilityCalculator.form.findField('nfldRoll_diameter').getValue());


if I switch the above line to:
calculateWebRollLength(frmUtilityCalculator.form.getValues());, i get the same error code: "Uncaught TypeError: Cannot call method 'getValues' of undefined"

YES i have searched the forms, all of which say to use getValues (which doesn't work since my form is undefined somehow?) Any insight would be appreciated.

realjax
4 May 2011, 1:03 PM
< insight >

1) there's no findfield method in Sencha Touch.
2) there's no basicForm either.
3) don't mix and match Touch and Extjs examples.
4) try frmUtilityCalculator.getValues() to get an object with key/value pairs or
5) try frmUtilityCalculator.getValues().nfldRoll_diameter to get its value.

< /insight >

;)

beefwellington
5 May 2011, 4:21 AM
< insight >

1) there's no findfield method in Sencha Touch.
2) there's no basicForm either.
3) don't mix and match Touch and Extjs examples.
4) try frmUtilityCalculator.getValues() to get an object with key/value pairs or
5) try frmUtilityCalculator.getValues().nfldRoll_diameter to get its value.

< /insight >

;)

thanks so much. i swear i checked to see if it was Ext JS and ppl were posting under the Sencha Touch forum or were using asking ST questions on other forums, either way thanks :D everything works now, wasted 4 hours trying to figure this out lol