PDA

View Full Version : Sum 2 numberfields value and display result into another numberfields (EXTJS MVC)



Sundayextjs
22 Mar 2016, 6:51 AM
Hello,

I would to show sum of two numberfields value into another numberfield but i don't know how to do.

Here is my numberfield declaration :


{
xtype: 'numberfield',
labelWidth: 250,
name: 'number1',
fieldLabel: 'Enter first number',
minValue: 1
},
{
xtype: 'numberfield',
labelWidth: 250,
name: 'number2',
fieldLabel: 'Enter Second number ',
minValue: 1
},
{
xtype: 'numberfield',
labelWidth: 250,
name: 'result',
fieldLabel: 'Result ',
minValue: 1
},


When user put number1 and number2 values, i want to assign automatically the sum result at third numberfield with my controller.

Can you help me ?

Regards,

jdkhamba
22 Mar 2016, 3:24 PM
Listen to change event on either field and call setValue on the third field in the event handler for each field.

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.form.field.Number-event-change