PDA

View Full Version : Basic panel question



dreamcaster
9 Feb 2010, 6:13 PM
Hello experts,

If create a new Ext.Panel with a layout of 'form', is it possible to get the field values without using find, findBy methods? Just like in Ext.form.FormPanel, getForm().getFieldValues().

Thanks

Eugen_
9 Feb 2010, 8:53 PM
Hi dreamcaster,

without find method:


var textfieldTest = new Ext.form.TextField({
fieldLabel: 'Test',
name: 'test'
});

var panelTest = new Ext.Panel({
items: [
textfieldTest
]
});

var sValue = textfieldTest.getValue();or if you need full analog getFieldValues(), you may use function like this:


var getFieldValues = function(panel, dirtyOnly){
var o = {},
n,
key,
val;
panel.items.each(function(f){
if(dirtyOnly !== true || f.isDirty()){
n = f.getName();
key = o[n];
val = f.getValue();

if(Ext.isDefined(key)){
if(Ext.isArray(key)){
o[n].push(val);
}else{
o[n] = [key, val];
}
}else{
o[n] = val;
}
}
});
return o;
}see http://www.extjs.com/deploy/dev/docs/source/BasicForm.html#method-Ext.form.BasicForm-getFieldValues

dreamcaster
9 Feb 2010, 10:58 PM
Hi, thanks for your reply. I'm gonna try your code. Thanks for sharing.