PDA

View Full Version : Better way for setting Default values for many textfields, NumberField, combobox??



Vinni
22 Sep 2010, 1:41 AM
Hi All,

I was wondering if there is a way to set default values for various textfields, NumberField, Combobox at common place.

I'm working on a project where the default values for many fields keeps changing in each release. I don't want to go through each page and change default values.

One way of doing is to have a common function which sets value for each field.. something like below

function XYZ()
{
A.setValue(..);
B.setValue(..);
...

Ext.getCmp('A_id').setValue(..);
Ext.getCmp('B_id').setValue(..);
..
...
}

Is there a better way to do it?

Thanks,
Vinni

laurentParis
22 Sep 2010, 4:28 AM
exemple code with textfield and default value = 'test'

Init method


Ext.ns('Ext.ux');
Ext.ux.TextFieldDefaultTest = Ext.extend(Ext.form.TextField, {
value: 'test'
});
Ext.reg('textfielddefaulttest ', Ext.ux.TextFieldDefaultTest);

.....


items: [{
xtype: 'textfielddefaulttest '
name: 'nameTest1'
},{
xtype: 'textfielddefaulttest '
name: 'nameTest2'
}]




After setting like this, for reset default value, use reset method about form