1. #1
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1
    Vote Rating
    1
    arindam.hit is on a distinguished road

      0  

    Default Answered: Not getting the values from some fields of the fieldset

    Answered: Not getting the values from some fields of the fieldset


    Hi,

    I am trying to get the values from a field set which is containg name, mobile number, email address and all those. Here is my field set code:

    Code:
    {                    xtype : 'fieldset',
                        docked : 'top',
                        id: 'signuptextfield',
                        margin : '10 0 0 0',
                        width : 600,
                        scrollable: true,
                        height : 180,
                        
                        items : [ {
                            xtype : 'textfield',
                            id : 'consumername',
                            style : 'font: Droid Sans',
                            label : 'Consumer Name',
                            labelWidth : '30%'
                        }, {
                            xtype : 'numberfield',
                            id : 'mobilenum',
                            style : 'font: Droid Sans',
                            label : 'Mobile',
                            labelWidth : '30%'
                        }, {
                            xtype : 'emailfield',
                            id : 'email',
                            label : 'Customer Email id',
                            labelWidth : '30%',
                            placeHolder : 'email@example.com'
                        }, {
                            xtype : 'textareafield',
                            id : 'adressfield',
                            style : 'font: Droid Sans',
                            label : 'Address',
                            labelWidth : '30%'
                        }, {
                            xtype : 'textfield',
                            id : 'areafield',
                            style : 'font: Droid Sans',
                            label : 'Area/Location',
                            labelWidth : '30%'
                        }, {
                            xtype : 'selectfield',
                            label : 'City',
                            labelWidth : '30%',
                            options : [ {
                                text : 'Bangalore',
                                value : 'first'
                            }, {
                                text : 'Delhi',
                                value : 'second'
                            }, {
                                text : 'Mumbai',
                                value : 'third'
                            } ]
                        }, {
                            xtype : 'numberfield',
                            id : 'pinfield',
                            style : 'font: Droid Sans',
                            label : 'Pincode*',
                            labelWidth : '30%'
                        }, ]
                    }, {
                        xtype : 'button',
                        height : 40,
                        id : 'submitbtn',
                        margin : '10 0 0 0',
                        ui : 'orange',
                        width : 220,
                        text : 'Submit'
                    }
    Now in the submit button click, i am trying to get this values:
    First, i tried with the below code:
    Code:
    var consumerName = Ext.getCmp('signuptextfield').getValues();
    But it is giving error:
    Code:
    Uncaught TypeError: Object [object Object] has no method 'getValues' at file:///android_asset/www/app/controller/MyController.js:164
    Then i tried with the below code:

    Code:
     onSubmitButtonTap : function(button, e, options) {
    function storeCustomerDetails(tx)
        {
            var consumerName = Ext.getCmp('consumername').getValue();
            var consumerMobNo = Ext.getCmp('mobilenum').getValue();
            var consumerEmail = Ext.getCmp('email').getValue();
            var consumerAddress = Ext.getCmp('adressfield').getValue();
            var consumerArea = Ext.getCmp('areafield').getValue();
            console.log("the datas are:"+consumerName);
            console.log("the datas are:"+consumerMobNo);
            console.log("the datas are:"+consumerEmail);
            console.log("the datas are:"+consumerAddress);
            console.log("the datas are:"+consumerArea);
       }
    But i am able to get only the Consumer name and mobile number. Other fields it is returning null..I do not know where is the exact problem..

    Help needed..

  2. Fieldset hasn't getValues(), but formpanel has.
    so:
    • Put fieldset inside formpanel.
    • To each component from fieldset add name attribute. (because getValues returns an object, where each key is name of appropriate component).
    • Form:
    PHP Code:
    Ext.create('Ext.form.Panel', {
        
    fullscreentrue,
        
    id'form',
        
    items: [
            {          
    xtype 'fieldset',
                        
    docked 'top',
                        
    id'signuptextfield',
                        
    margin '10 0 0 0',
                        
    width 600,
                        
    scrollabletrue,
                        
    height 180,
                        
    items : [ {
                            
    xtype 'textfield',
                            
    name'consumername',
                            
    id'consumername',
                            
    style 'font: Droid Sans',
                            
    label 'Consumer Name',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'numberfield',
                            
    id'mobilenum',
                            
    name'mobilenum',
                            
    style 'font: Droid Sans',
                            
    label 'Mobile',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'emailfield',
                            
    id'email',
                            
    name'email',
                            
    label 'Customer Email id',
                            
    labelWidth '30%',
                            
    placeHolder 'email@example.com'
                        
    }, {
                            
    xtype 'textareafield',
                            
    id'adressfield',
                            
    name'adressfield',
                            
    style 'font: Droid Sans',
                            
    label 'Address',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'textfield',
                            
    id'areafield',
                            
    name'areafield',
                            
    style 'font: Droid Sans',
                            
    label 'Area/Location',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'selectfield',
                            
    label 'City',
                            
    name'city',
                            
    labelWidth '30%',
                            
    options : [ {
                                
    text 'Bangalore',
                                
    value 'first'
                            
    }, {
                                
    text 'Delhi',
                                
    value 'second'
                            
    }, {
                                
    text 'Mumbai',
                                
    value 'third'
                            
    } ]
                        }, {
                            
    xtype 'numberfield',
                            
    name'pinfield',
                            
    id'pinfield',
                            
    style 'font: Droid Sans',
                            
    label 'Pincode*',
                            
    labelWidth '30%'
                        
    }, ]
                    }, {
                        
    xtype 'button',
                        
    height 40,
                        
    id 'submitbtn',
                        
    margin '10 0 0 0',
                        
    ui 'orange',
                        
    width 220,
                        
    text 'Submit'
                    
    }
        ]
    }); 
    • To get values:
    PHP Code:
    Ext.getCmp('form').getValues(); 
    ,

  3. #2
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1
    Vote Rating
    1
    arindam.hit is on a distinguished road

      0  

    Default Not getting the values from some fields of the fieldset

    Not getting the values from some fields of the fieldset


    Hi,

    I am trying to get the values from a field set which is containg name, mobile number, email address and all those. Here is my field set code:

    Code:
    {                    xtype : 'fieldset',
                        docked : 'top',
                        id: 'signuptextfield',
                        margin : '10 0 0 0',
                        width : 600,
                        scrollable: true,
                        height : 180,
                        
                        items : [ {
                            xtype : 'textfield',
                            id : 'consumername',
                            style : 'font: Droid Sans',
                            label : 'Consumer Name',
                            labelWidth : '30%'
                        }, {
                            xtype : 'numberfield',
                            id : 'mobilenum',
                            style : 'font: Droid Sans',
                            label : 'Mobile',
                            labelWidth : '30%'
                        }, {
                            xtype : 'emailfield',
                            id : 'email',
                            label : 'Customer Email id',
                            labelWidth : '30%',
                            placeHolder : 'email@example.com'
                        }, {
                            xtype : 'textareafield',
                            id : 'adressfield',
                            style : 'font: Droid Sans',
                            label : 'Address',
                            labelWidth : '30%'
                        }, {
                            xtype : 'textfield',
                            id : 'areafield',
                            style : 'font: Droid Sans',
                            label : 'Area/Location',
                            labelWidth : '30%'
                        }, {
                            xtype : 'selectfield',
                            label : 'City',
                            labelWidth : '30%',
                            options : [ {
                                text : 'Bangalore',
                                value : 'first'
                            }, {
                                text : 'Delhi',
                                value : 'second'
                            }, {
                                text : 'Mumbai',
                                value : 'third'
                            } ]
                        }, {
                            xtype : 'numberfield',
                            id : 'pinfield',
                            style : 'font: Droid Sans',
                            label : 'Pincode*',
                            labelWidth : '30%'
                        }, ]
                    }, {
                        xtype : 'button',
                        height : 40,
                        id : 'submitbtn',
                        margin : '10 0 0 0',
                        ui : 'orange',
                        width : 220,
                        text : 'Submit'
                    }
    Now in the submit button click, i am trying to get this values:
    First, i tried with the below code:
    Code:
    var consumerName = Ext.getCmp('signuptextfield').getValues();
    But it is giving error:
    Code:
    Uncaught TypeError: Object [object Object] has no method 'getValues' at file:///android_asset/www/app/controller/MyController.js:164
    Then i tried with the below code:

    Code:
     onSubmitButtonTap : function(button, e, options) {
    function storeCustomerDetails(tx)
        {
            var consumerName = Ext.getCmp('consumername').getValue();
            var consumerMobNo = Ext.getCmp('mobilenum').getValue();
            var consumerEmail = Ext.getCmp('email').getValue();
            var consumerAddress = Ext.getCmp('adressfield').getValue();
            var consumerArea = Ext.getCmp('areafield').getValue();
            console.log("the datas are:"+consumerName);
            console.log("the datas are:"+consumerMobNo);
            console.log("the datas are:"+consumerEmail);
            console.log("the datas are:"+consumerAddress);
            console.log("the datas are:"+consumerArea);
       }
    But i am able to get only the Consumer name and mobile number. Other fields it is returning null..I do not know where is the exact problem..

    Help needed..

  4. #3
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    Quote Originally Posted by arindam.hit View Post
    Code:
    Uncaught TypeError: Object [object Object] has no method 'getValues' at file:///android_asset/www/app/controller/MyController.js:164
    Is the fieldset being referenced here? (as [object Object])

  5. #4
    Sencha User
    Join Date
    Jul 2012
    Posts
    3
    Answers
    1
    Vote Rating
    0
    .Volodymyr is on a distinguished road

      0  

    Default


    Fieldset hasn't getValues(), but formpanel has.
    so:
    • Put fieldset inside formpanel.
    • To each component from fieldset add name attribute. (because getValues returns an object, where each key is name of appropriate component).
    • Form:
    PHP Code:
    Ext.create('Ext.form.Panel', {
        
    fullscreentrue,
        
    id'form',
        
    items: [
            {          
    xtype 'fieldset',
                        
    docked 'top',
                        
    id'signuptextfield',
                        
    margin '10 0 0 0',
                        
    width 600,
                        
    scrollabletrue,
                        
    height 180,
                        
    items : [ {
                            
    xtype 'textfield',
                            
    name'consumername',
                            
    id'consumername',
                            
    style 'font: Droid Sans',
                            
    label 'Consumer Name',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'numberfield',
                            
    id'mobilenum',
                            
    name'mobilenum',
                            
    style 'font: Droid Sans',
                            
    label 'Mobile',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'emailfield',
                            
    id'email',
                            
    name'email',
                            
    label 'Customer Email id',
                            
    labelWidth '30%',
                            
    placeHolder 'email@example.com'
                        
    }, {
                            
    xtype 'textareafield',
                            
    id'adressfield',
                            
    name'adressfield',
                            
    style 'font: Droid Sans',
                            
    label 'Address',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'textfield',
                            
    id'areafield',
                            
    name'areafield',
                            
    style 'font: Droid Sans',
                            
    label 'Area/Location',
                            
    labelWidth '30%'
                        
    }, {
                            
    xtype 'selectfield',
                            
    label 'City',
                            
    name'city',
                            
    labelWidth '30%',
                            
    options : [ {
                                
    text 'Bangalore',
                                
    value 'first'
                            
    }, {
                                
    text 'Delhi',
                                
    value 'second'
                            
    }, {
                                
    text 'Mumbai',
                                
    value 'third'
                            
    } ]
                        }, {
                            
    xtype 'numberfield',
                            
    name'pinfield',
                            
    id'pinfield',
                            
    style 'font: Droid Sans',
                            
    label 'Pincode*',
                            
    labelWidth '30%'
                        
    }, ]
                    }, {
                        
    xtype 'button',
                        
    height 40,
                        
    id 'submitbtn',
                        
    margin '10 0 0 0',
                        
    ui 'orange',
                        
    width 220,
                        
    text 'Submit'
                    
    }
        ]
    }); 
    • To get values:
    PHP Code:
    Ext.getCmp('form').getValues(); 
    ,

  6. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Answers
    5
    Vote Rating
    10
    pepperseb is on a distinguished road

      1  

    Default


    You have to define your fieldset within a formpanel (Ext.form.Panel) and then you can use

    Code:
    form.getValues();
    Moreover, you should have a name property bound to each field as, according to the doc,
    getValues returns an object containing the value of each field in the form, keyed to the field's name.

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Please don't double post. I have merged your other thread to clean up.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.