View Full Version : fieldset problems...

11 Apr 2014, 12:12 AM
Hey guys! :)

My colleague made a model for a fieldset with two numberfields in it.
Now I have to set a default-value to only one of this numberfields, but I don't know how to approach only to one :-?

Here's the code of the fieldset(view):

addToGroup: function(field) {
var group = Ext.getCmp(field.typeName);
if (!group) {
group = this.add({xtype: 'fieldset', title: field.typeName, id: field.typeName,
defaults: {
xtype: 'numberfield',
fieldStyle: 'text-align:right;',
align: 'right',
layout: 'anchor',
anchor: '100%',
allowNegative: false,
labelWidth: 140, width: 230,
value: 0, minValue: 0, maxValue: 999999
var value = field.value || 100;
var isDecimal = this.decimalFields.hasOwnProperty(field.id);
var fieldCtl = group.add({
fieldLabel: Ext.String.trim(field.name),
name: Ext.String.trim(field.fieldName),
value: value,
allowDecimals: (isDecimal) ? true : false,
decimalPrecision: (isDecimal) ? this.decimalFields[field.id] : 0,
tabIndex: this.currTabIdx++
this.inputFields[field.id] = fieldCtl;

if (this.firstField === null)
this.firstField = fieldCtl;
this.lastField = fieldCtl;

Aaand a picture for better explanation:


The value in the first numberfield should be zero, the value in the second should default to 100 ...

Thank you very much for support! :)

11 Apr 2014, 12:38 AM
whats in the field object you receive as an argument? does it have a value property? do a console.log to investigate or your debugging features of Firebug or Chrome (press F12). see whats the value of field.value and what value is assigned to the variable value after this line:

var value = field.value || 100;