Results 1 to 6 of 6

Thread: Loading the Store with the values from the form

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    34
    Vote Rating
    0
      0  

    Default 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

  2. #2
    Sencha Premium Member danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    416
    Answers
    1
    Vote Rating
    207
      0  

    Default

    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) use
    Code:
    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

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    34
    Vote Rating
    0
      0  

    Default

    I got the solution.
    REPLACE
    alert(form.getValues())
    WITH
    Ext.Msg.alert(
    'FormValues', JSON.stringify(form.getValues(), null, 100 ));

  4. #4
    Sencha User
    Join Date
    Nov 2012
    Posts
    34
    Vote Rating
    0
      0  

    Default

    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);



  5. #5
    Sencha Premium User suzuki1100nz's Avatar
    Join Date
    Apr 2011
    Location
    New Zealand
    Posts
    714
    Answers
    45
    Vote Rating
    236
      0  

    Default

    Does the object returned from form.getValues() match the store model objects?
    Do you get an error?

  6. #6
    Sencha User
    Join Date
    Nov 2012
    Posts
    34
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by suzuki1100nz View Post
    Does the object returned from form.getValues() match the store model objects?
    Do you get an error?
    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();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •