1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    99
    Vote Rating
    6
    Andreas Samjeske is on a distinguished road

      0  

    Default Unanswered: getValue doesn't care about Format of NumberField

    Unanswered: getValue doesn't care about Format of NumberField


    Have a look at the spinnerField (Duration) here:
    http://www.sencha.com/examples/explo...e:formsexample

    If I put in 1.23 and leave the field, it is rounded to 1.2 since Format for the Field was set to exact one decimal digit.
    Code:
    setFormat(NumberFormat.getFormat("0.0"));
    So far, so good. But the ToolTip on the upper right shows
    Duration Changed
    1.23
    I guess, spinnerField.getCurrentValue() delivers 1.2
    while spinnerField.getValue() delivers 1.23

    This seems odd to me. I think, .getValue() should be in according format, too.
    Am I missing something? Whats the reason for this behavior?

    Thanx.

  2. #2
    Sencha User
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    98
    Answers
    15
    Vote Rating
    7
    vardhan22 is on a distinguished road

      0  

    Default


    I also had the same issue.
    Whatever i have read, i understood the followring-

    getCurrentValue returns you the current text on the field, and the formatter changes the display text on the field. Therefore, currentValue is returning the correct value.

    The value for any field is set when ValueChangeEvent is fired, the value assigned is equal to currentValue, at that time, BlurEvent is not yet fired so getCurrentValue, getValue, getText all will return same values, which is 1.23 in your case. When blurEvent is fired, formatting takes place and getText, getCurentValue is returning 1.2. But, as setValue is already done with currentValue 1.23. the getValue is still returning 1.23.

    To obtain correct result, just addBlurHandler and do
    Code:
    setValue(spinnerField.getCurrentValue());

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    99
    Vote Rating
    6
    Andreas Samjeske is on a distinguished road

      0  

    Default


    Quote Originally Posted by vardhan22 View Post
    ...
    The value for any field is set when ValueChangeEvent is fired, the value assigned is equal to currentValue, at that time, BlurEvent is not yet fired so getCurrentValue, getValue, getText all will return same values, which is 1.23 in your case. When blurEvent is fired, formatting takes place and getText, getCurentValue is returning 1.2. But, as setValue is already done with currentValue 1.23. the getValue is still returning 1.23.
    In the example the tooltip is shown onValueChange:
    Code:
        spinnerField.addValueChangeHandler(new ValueChangeHandler<Double>() {
     
          @Override
          public void onValueChange(ValueChangeEvent<Double> event) {
            Info.display("Duration Changed",
                "Duration changed to " + event.getValue() == null ? "nothing" : event.getValue() + "");
          }
        });
    Since that only appears onBlur, it seem like the value is only updated onBlur.
    Quote Originally Posted by vardhan22 View Post
    To obtain correct result, just addBlurHandler and do
    Code:
    setValue(spinnerField.getCurrentValue());
    Hmm, that' in interesting idea. Are there any sideeffects?

  4. #4
    Sencha User
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    98
    Answers
    15
    Vote Rating
    7
    vardhan22 is on a distinguished road

      0  

    Default


    There should not be any side effects, i am not getting any.
    Just take care, if Value of field is changing, then you are doing something, you have to fire ValueChangeEvent manually.

    Code:
    spinnerField.setValue(spinnerField.getValue(),true);
    If you are using this, and getting any issue, please let me know also.

    And you can verify the currentvalue remains 1.23 when ValueChnageEvent is fired, by using sysouts there

  5. #5
    Sencha User
    Join Date
    Jul 2011
    Posts
    99
    Vote Rating
    6
    Andreas Samjeske is on a distinguished road

      0  

    Default


    I would like to hear a word from sencha about this.

    Testcase:
    - Go to http://www.sencha.com/examples/#Exam...e:formsexample
    - Enter 0.15 for "Duration"

    Result: Box shows 0.2, Dialog says 0.15
    Is this expected behavior?

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi