PDA

View Full Version : get values from dynamic created fields



rafmak1
7 Apr 2016, 7:25 AM
Hi,
i have a combobox with numeric values .


var storeFrequency = new Ext.data.SimpleStore({
fields: ['value']
, data: [['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9'], ['10']]

});



{
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

}

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.

Gary Schlosberg
7 Apr 2016, 11:42 AM
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?