Results 1 to 3 of 3

Thread: Accept NUM_PERIOD when the decimal separator is ','

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    19

    Default Accept NUM_PERIOD when the decimal separator is ','

    If I have a numberfield with decimalseparator = ',' (comma) then the field do not accept the NUM_PERIOD key.
    ¿What can i do to allow NUM_PERIOD and put a comma instead of a dot?

    ¿May I ensure the NUM_PERIOD key will allways take as the decimal separator of my number fields, no matter which one is set (comma or period).?

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Posts
    19

    Default

    I solved using keyup listener
    Code:
    keyup : function(me, e) {
        if (e.getCharCode() == e.NUM_PERIOD) {
             var value = me.getRawValue();
             var dom = me.inputEl.dom;
             var nStart = dom.selectionStart;
              me.setRawValue(value.substring(0, nStart) + me.decimalSeparator + value.substring(nStart));
              dom.selectionStart = dom.selectionEnd = nStart + 1;
        }
    }

  3. #3
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,018
    Answers
    1

    Default

    @jconcept, thanks for sharing your solution!

    The only think that I would replace:
    Code:
    me.setRawValue(value.substring(0, nStart) + me.decimalSeparator + value.substring(nStart));
    with
    Code:
    me.setRawValue(value.substring(0, nStart) + me.decimalSeparator);
    With your initial code it misbehaves if select text in a NumberField.
    Object.NET
    Frameworks and Tools for .NET Developers
    --------------------------------------------------
    Ext.NET - Ext JS for ASP.NET - Examples | Twitter
    Bridge.NET - Write C#. Run JavaScript! - Live | Twitter
    --------------------------------------------------

Similar Threads

  1. Decimal separator
    By priand in forum Sencha GXT 3.1
    Replies: 0
    Last Post: 1 Sep 2016, 5:42 AM
  2. NumberField + decimal separator
    By fother in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 26 Aug 2009, 5:55 AM
  3. NumberField with , for decimal separator
    By Pmithrandir in forum Ext GWT: Help & Discussion (1.x)
    Replies: 4
    Last Post: 18 Dec 2008, 7:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •