PDA

View Full Version : [CLOSED] NumberField setRawValue can still fire changed event



glenh
Mar 25, 2014, 9:46 PM
Hi

I have a situation where I don't want to fire the change event on a NumberField. I use setRawValue() as this will bypass the change event (among other things). I find this does work except when I put the focus back to that NumberField and then it loses focus the change even then fires.

To replicate use the following code:



<ext:NumberField ID="nf" runat="server">
<Listeners>
<Render Single="true" Handler="this.setRawValue(1)" />
<Change Handler="alert('changed');" />
</Listeners>
</ext:NumberField>

<ext:Button runat="server" Text="Change">
<Listeners>
<Click Handler="#{nf}.setRawValue(25);" />
</Listeners>
</ext:Button>


Load the page and then click the button. This will change the rawValue from 1 to 25. The change event does not fire. Put the cursor in the numberfield and then make it lose the focus by clicking anywhere else. The change event now fires.

Subsequently, this does not happen if it is a TextField.

Thanks
Glen

Daniil
Mar 28, 2014, 2:40 AM
Hi Glen,

Yes, it looks like the setRawValue method works inconsistently with the Change event.

I suggest the following solution for you requirement. Is it OK for you?

#{nf}.suspendEvent('change');
#{nf}.setRawValue(25);
#{nf}.resumeEvent('change');

glenh
Apr 01, 2014, 4:55 AM
Hi Danil

Unfortunately this does not fix the problem. The problem still occurs as described in my example.

Thanks
Glen

Daniil
Apr 01, 2014, 5:38 PM
Sorry, I meant this:

#{nf}.suspendEvent('change');
#{nf}.setValue(25);
#{nf}.resumeEvent('change');

glenh
Apr 02, 2014, 1:08 AM
Thank you - this works.