Results 1 to 2 of 2

Thread: Select/Date/Radio Field data not stored using getValues()

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    Mumbai, India
    Posts
    120
    Answers
    11
    Vote Rating
    4
      0  

    Default Answered: Select/Date/Radio Field data not stored using getValues()

    Hi,

    I have a form panel containing various text fields, one selectfield, one datepickerfield, and one radiofield. I have a save button that when pressed dispatches to a controller which saves the data to the store and then populates a list that uses that store. The textfield data saves to the store wid no problems. But the select, datepicker and radio fields do not. Please help.

    Heres the code for the form :

    Code:
    var formPane = new Ext.form.FormPanel ({
        id : 'formPane',
        items: [
            {
                xtype : 'fieldset',
                title : 'Form Details',
                defaults : {
                      labelAlign : 'left',
                      labelWidth : '40%',
                      required : false,
                      useClearIcon : true,
                      autoCapitalize: false
                },
                items : [
                    {
                        xtype: 'textfield',
                        id : 'name',
                        name : 'name',
                        label: 'Name'
                    },
                    {
                        xtype: 'selectfield',
                        name : 'categ',
                        id : 'categ',
                        label: 'Category',
                        valueField : 'categv',
                        displayField : 'title',
                        store : BReimb.stores.categsStore
                    },
                    {
                        xtype: "datepickerfield",
                        name: "date",
                        id : 'date',
                        label: "Date",
                        picker: {yearFrom: 2010}  
                    },
                ]
            },
            {
                xtype : 'fieldset',
                title : 'Radio Details',
                layout : 'hbox',
                defaults : {xtype : 'radiofield'},
                items : [
                    {name : 'paymeth', label: 'Cash', value : 'red', width: '50%'},
                    {name : 'paymeth', width: '50%', label: 'Card' , checked : true, value : 'green'}
                ]
            }
       ]
    });
    Here's the save button in the toolbar :
    Code:
    {
                xtype : 'button',
                text : 'save',
                ui : 'confirm',
                width : '25%',
                handler : function() {
                    Ext.dispatch({
                        controller : 'Users',
                        action : 'save',
                        data : Ext.getCmp('formPane').getValues()
                    });
                 }
    }
    My Controller :
    Code:
    save : function(params){
            App.stores.ListStore.create(params.data);
    }
    The store is set to autoLoad
    The model has a "localstorage" proxy & has string fields with matching ids to the form.

    What am I doing wrong ???

  2. Code:
    new Ext.form.FormPanel({
        fullscreen : true,
        items      : [
            {
                xtype : 'fieldset',
                title : 'Form Details',
                defaults : {
                      labelAlign : 'left',
                      labelWidth : '40%',
                      required : false,
                      useClearIcon : true,
                      autoCapitalize: false
                },
                items : [
                    {
                        xtype: 'textfield',
                        id : 'name',
                        name : 'name',
                        label: 'Name'
                    },
                    {
                        xtype: "datepickerfield",
                        name: "date",
                        id : 'date',
                        label: "Date",
                        picker: {yearFrom: 2010}
                    }
                ]
            },
            {
                xtype : 'fieldset',
                title : 'Radio Details',
                layout : 'hbox',
                defaults : {xtype : 'radiofield'},
                items : [
                    {name : 'paymeth', label: 'Cash', value : 'red', width: '50%'},
                    {name : 'paymeth', width: '50%', label: 'Card' , checked : true, value : 'green'}
                ]
            }
        ],
        dockedItems : [
            {
                xtype : 'toolbar',
                dock  : 'bottom',
                items : [
                    {
                        text    : 'Save',
                        ui      : 'confirm',
                        handler : function(btn) {
                            var form = btn.up('form');
    
                            console.log(form.getValues());
                        }
                    }
                ]
            }
        ]
    });
    The log prints out:

    Code:
    {
        date    : null,
        name    : "",
        paymeth : "green"
    }
    Radios and checkboxes don't have a value if they are not checked.

  3. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,060
    Answers
    3976
    Vote Rating
    1389
      0  

    Default

    Code:
    new Ext.form.FormPanel({
        fullscreen : true,
        items      : [
            {
                xtype : 'fieldset',
                title : 'Form Details',
                defaults : {
                      labelAlign : 'left',
                      labelWidth : '40%',
                      required : false,
                      useClearIcon : true,
                      autoCapitalize: false
                },
                items : [
                    {
                        xtype: 'textfield',
                        id : 'name',
                        name : 'name',
                        label: 'Name'
                    },
                    {
                        xtype: "datepickerfield",
                        name: "date",
                        id : 'date',
                        label: "Date",
                        picker: {yearFrom: 2010}
                    }
                ]
            },
            {
                xtype : 'fieldset',
                title : 'Radio Details',
                layout : 'hbox',
                defaults : {xtype : 'radiofield'},
                items : [
                    {name : 'paymeth', label: 'Cash', value : 'red', width: '50%'},
                    {name : 'paymeth', width: '50%', label: 'Card' , checked : true, value : 'green'}
                ]
            }
        ],
        dockedItems : [
            {
                xtype : 'toolbar',
                dock  : 'bottom',
                items : [
                    {
                        text    : 'Save',
                        ui      : 'confirm',
                        handler : function(btn) {
                            var form = btn.up('form');
    
                            console.log(form.getValues());
                        }
                    }
                ]
            }
        ]
    });
    The log prints out:

    Code:
    {
        date    : null,
        name    : "",
        paymeth : "green"
    }
    Radios and checkboxes don't have a value if they are not checked.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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