PDA

View Full Version : How getValue() of 'Form' Layout



Flcn
20 Jul 2010, 4:32 AM
Hello
i have one small window

new Ext.Window({
width : 300,
height : 140,
id : "MyFormLayoutId",
layout : 'form',
items : [
{
fieldLabel : "Type",
xtype : 'combo',
name : 'type',
triggerAction: 'all',
store : new Ext.data.ArrayStore({
url : rootUrl + 'get_param_types/',
fields : [
'id',
'name'
]
}),
mode : 'remote',
valueField : 'id',
displayField : 'name',
columnWidth : .5

},
{
fieldLabel : "Values",
xtype : 'field'
}
],
buttons : [
{
text : "Save",
listeners : {
'click': function(){
....
}}
},
{
text : "Cancel"
}

]
}).show()

and when i click on Save button. i want to getValues() of all my FormLayout(2 elements) (like i can do with form)
How can i do it?

Thanks

Condor
20 Jul 2010, 4:45 AM
getValues() is only available in an Ext.form.BasicForm.

You could create an instance of Ext.form.BasicForm with the el set to the window body, but for just 2 values I would just query the two fields.

Animal
20 Jul 2010, 4:51 AM
Maybe a Container override?




Ext.override(Ext.Container, {
getValues: function() {
var o = {},
n,
key,
val;
this.cascade(function(f) {
if (f.getValue) {
n = f.getName()||f.id;
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;
}
});