View Full Version : One field effect another editable field

13 Jul 2012, 7:13 AM
How can I get one field to change the editable value of another field. I have two weight fields, one in pounds and one in tons. I have it setup so that when you edit one of the fields it changes the value of the other field with:

[if (e.field == 'FDNETLBS'){
if (e.value !== 0) {
var weight = e.value/2000;
} else {
var weight = 0;

if (e.field == 'TONS'){
var weight = e.value * 2000;

This changes the uneditable value, but the value that shows as the editable value is the previous value of the field that was updated. Basically if I put in 2000 lbs the value for Tons changes to 1 ton, but the value that shows when you go to the field to edit is zero, if it had no value for tons before. Any idea to get it to update the editable value?

13 Jul 2012, 8:47 PM
This should work ..

var form = Ext.create('Ext.form.Panel', {
title: 'Contact Info',
width: 300,
bodyPadding: 10,
renderTo: Ext.getBody(),
items: [{
xtype: 'textfield',
name: 'name',
fieldLabel: 'Name',
listeners: {
blur: function(field) {
var email = form.down('#emailid');
email.setValue(field.value); // update the editor instead of store
}, {
xtype: 'textfield',
name: 'email',
itemId: 'emailid',
fieldLabel: 'Email Address'