PDA

View Full Version : How to refresh NumberField value when item selected in ComboBox change?



volperubbia
13 Jun 2010, 11:12 PM
Hi,
i have a textfield that depend from a CompoBox and I want refresh its
value when change item in ComboBox.



var txtCapacity = new Ext.form.NumberField({ ... });
var ddlType = new Ext.form.ComboBox({ ... });

ddlType.on("select", function() {
txtCapacity.value = this.store.data.items[this.selectedIndex].data.CAPACITY;
alert(txtCapacity.value); // IT IS OK, BUT NO EFFECT ON txtCapacity
});

var objForm = new Ext.form.FormPanel({
...
items: [ddlType, txtCapacity],
...
});

var objWinForm = new Ext.Window({
layout: 'fit',
modal: true,
items: [objForm]
});
objWinForm.show();


In this code alert(txtCapacity.value) in onSelect shows the correct value,
but realy txtCapacity don't change its value ...

How can I refresh txtCapacity?
Tks.

Condor
13 Jun 2010, 11:30 PM
Use the setValue() method instead of assigning directly to the value property.

fay
14 Jun 2010, 4:17 AM
Use the setValue (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.NumberField) method instead of trying to modify a config option. Also use FireFox/FireBug instead of "alerts" when developing/debugging.

pavanextjs
14 Jun 2010, 5:34 AM
Use something like this...follow API for the list of parameters that can be used for the event listeners.


ddlType.on("select", function(combo, record, index) {
txtCapacity.setValue(record.data.CAPACITY);
});

volperubbia
14 Jun 2010, 10:27 AM
Tks, it's ok.



ddlType.on("select", function(combo, record, index) {
txtCapacity.setValue(record.data.CAPACITY);
});