Actually I have an ExtJs script to create form with a Window below.
var frmAccount = Ext.create('Ext.form.Panel',{
bodyPadding: 5,
frame : true,
items :[
{
xtype : 'textfield',
fieldLabel : 'Account Number',
name : 'accountNum'
},{
xtype : 'textfield',
fieldLabel : 'Company',
name : 'company'
},{
xtype : 'textfield',
fieldLabel : 'Office',
name : 'office'
},{
xtype : 'textareafield',
fieldLabel : 'Address',
name : 'address',
width : 350
},{
xtype : 'textfield',
fieldLabel : 'City',
name : 'city'
},{
xtype : 'textfield',
fieldLabel : 'Country',
name : 'nation'
}]
});
var winAddAccount = Ext.create('widget.window',{
id : 'addAccount',
title : 'Filter Record',
width : 400,
height : 300,
modal : true,
closeAction : 'hide',
items : frmAccount,
layout : 'fit',
bodyPadding: 5,
buttons:[
{
text : 'Find',
handler: function(){
//console.log(form value);
}
},
{
text : 'Cancel',
handler: function(){
winAddAccount.hide();
}
}
]
});
I just want to get values from the form after I click 'Find' button.
But I don't know to get values from the form after I click 'Find' button.
hopefully I can see the value with console.log
script on handler.
Kindly please help me to solve or suggest an idea.
Thanks.
try this
text : 'Find',
handler: function(btn){
var win = btn.up('window'),
form = win.down('form');
console.log(form.getForm().getValues());
}
And in addition I recommend you to look through the tutorials provided by sencha and to take a look at the API which also contains plenty of examples
To get only the value of a specific field do (this example assume the field exist!)
text : 'Find',
handler: function(btn){
var win = btn.up('window'),
form = win.down('form');
console.log(form.getForm().findField('NamePropertyValue').getSubmitValue() /*or call getSubmitData() or just getValue()*/);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With