Hybrid View
-
15 Nov 2012 9:25 PM #1
Unanswered: Loading the Store with the values from the form
Unanswered: Loading the Store with the values from the form
Hi,
I'm trying to load the Store with the values from the form (vales from the texfield acts as input)
Here is my code
var form = Ext.create('Ext.form.Panel', {
fullscreen: true,
items: [ {
xtype: 'textfield',
name: 'name',
label: 'Name'
}, {
xtype: 'emailfield',
name: 'email',
label: 'Email'
}, {
xtype: 'passwordfield',
name: 'password',
label: 'Password'
}, {
xtype: 'button',
text: 'Submit',
listeners: {
tap: function() {
alert(form.getValues());
}
}
}]
});
I was expecting the entered input values to appear in the alert. Instead I'm getting
[object Object]
Can anyone please point out what is wrong here?
Thanks
-
15 Nov 2012 10:56 PM #2Sencha Premium Member
- Join Date
- Feb 2009
- Location
- Kragujevac, Serbia
- Posts
- 359
- Vote Rating
- 2
- Answers
- 1
Take a look at the API http://docs.sencha.com/touch/2-0/#!/...thod-getValues
As it states "Returns an object containing the value of each field in the form, keyed to the field's name. For groups of checkbox fields with the same name, it will be arrays of values"
So everything is as it should be. If you want to alert some specific value (eg. email) useCode:alert(form.getValues().email);
All Best
---
Željko Mitrović
http://skitanja.blogspot.com/
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding
-
15 Nov 2012 11:09 PM #3
Hi,
I'm getting the values. But I'm not able to save it in the store.
Ive used the following code:
var values= form.getValues();
store.add(values);
-
15 Nov 2012 11:45 PM #4
Does the object returned from form.getValues() match the store model objects?
Do you get an error?
-
16 Nov 2012 2:07 AM #5
Im getting the values when I used the alert.
But I'm not sure if it is going to the Store. How can one check that?
Ive used the following code:
var values= JSON.stringify(formPanel.getValues(), null, 100);
Ext.Msg.alert('Form Values',values)
Ext.getStore('Store1').add(values);
store.sync();
-
15 Nov 2012 10:57 PM #6
I got the solution.
REPLACE
alert(form.getValues())
WITH
Ext.Msg.alert('FormValues', JSON.stringify(form.getValues(), null, 100 ));


Reply With Quote


