Results 1 to 2 of 2

Thread: get values from dynamic created fields

  1. #1
    Sencha User
    Join Date
    Jan 2016
    Posts
    12

    Default get values from dynamic created fields

    Hi,
    i have a combobox with numeric values .
    Code:
       var storeFrequency = new Ext.data.SimpleStore({
                fields: ['value']
                    , data: [['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9'], ['10']]
            
            });
    Code:
      
    {  
                                                                typeAhead: false
                                                               , triggerAction: 'all'
                                                               , lazyRender: false,                              
                                                                width:          100,
                                                                xtype:          'combo',
                                                                mode:           'local',
                                                                value:          '',
                                                                fieldLabel:     '',
                                                                name:           '',
                                                                id:             'frequency',
                                                                hiddenName:     '',
                                                                displayField:   'value',
                                                                valueField:     'value',
                                                                allowBlank:true,
                                                                hidden:false,
                                                               store: storeFrequency
                                                                
                                                            }
    Code:
           Ext.getCmp('frequency').on('select',function(){
                     var frequency=   parseInt( Ext.getCmp('frequency').getValue());                                 
                                                               
                            fieldset.removeAll();                   
                           for (i=0;i<frequency;i++)
                             {                        
                                fieldset.add({ 
                                            xtype      : 'compositefield',                                       
                                            id:i,
                                            fieldLabel : '',
                                            items      : [
                                                             {fieldLabel: '',
                                                             id: 'days'+i
                                                           , name: 'days'+i
                                                           , xtype: 'textfield'
                                                           , width: 80
                                                            }
                                                           ,{
                                    
                                                                width:          100,
                                                                xtype:          'combo',
                                                                mode:           'local',
                                                                value:          '',
                                                                triggerAction:  'all',
                                                                forceSelection: true,
                                                                editable:       false,
                                                                fieldLabel:     '',
                                                                name:           'unit'+i,
                                                                id:             'unit'+i,
                                                                hiddenName:     '',
                                                                displayField:   'name',
                                                                valueField:     'value',
                                                                allowBlank:true,
                                                                store:          new Ext.data.JsonStore({
                                                                    fields : ['name', 'value'],
                                                                    data   : [
                                                                        {name : 'Months',  value: 'months'},
                                                                        {name : 'Weeks',  value: 'weeks'},
                                                                        {name : 'Days',  value: 'days'}
                                                           
                                                                    ]
                                                                })
                                                             }
                                                            ,{
                                                                  xtype: 'displayfield', 
                                                                  value: 'from  '
                                                             }
                                                            ,{
                                                                width:          200,
                                                                xtype:'textfield',
                                                                mode:           'local',
                                                                value:          '',
                                                                triggerAction:  'all',
                                                                forceSelection: true,
                                                                editable:       false,
                                                                fieldLabel:     '',
                                                                name:           'from'+i,
                                                                id:             'from'+i,
                                                                hiddenName:     '',
                                                                displayField:   'name',
                                                                valueField:     'value',
                                                                allowBlank:true                                               
                                                              }
                                                             ,{
                                                                 xtype: 'displayfield',
                                                                 value: 'or  '
                                                             }
                                                             ,{
                                                                 fieldLabel: ''
                                                                 ,xtype:'datefield'
                                                                 ,id: 'date'+i
                                                                 ,name: 'date'+i
                                                                 ,width:100
                                                                  , allowBlank:true
                                                               }
                                                            ]
                                                })
                                    fieldset.doLayout();
                                  
    
                                        
                              }
    I wanted to get all values in the compositefield in an array in order to encode them in json(same idea when we encode a grid ) and store them in my database.
    Regards.

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Does the data not show up at your server in JSON? Can you parse that in your server script to put the fields in one array, or are you required to prepare the data before passing it?

Similar Threads

  1. Container / Panel is not scrollable when dynamic select fields are created.
    By jasbir.purba in forum Sencha Touch 2.x: Discussion
    Replies: 4
    Last Post: 30 Aug 2013, 2:50 PM
  2. [INFOREQ] Form rendering fields with values as empty fields after submit
    By Bohauch in forum Sencha Touch 2.x: Bugs
    Replies: 8
    Last Post: 27 Jun 2012, 9:41 PM
  3. Dynamic created XMLReaders for dynamic load of models
    By SiCawn in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 18 Apr 2011, 11:22 PM
  4. Replies: 0
    Last Post: 11 Jun 2007, 5:24 AM

Posting Permissions

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