Supporting both comma and dot for decimal input

6 posts, 0 answers
  1. Jean-François
    Jean-François avatar
    26 posts
    Member since:
    Dec 2012

    Posted 23 Jun 2014 Link to this post

    Hi, 

    Our whole system is design for fast data input and one requirement is that both dot and comma be accepted as decimal delimiter. Input can be both "12,12" and "12.12". It's okay if both display the afterwards, as long as the input allows for it. In fact, .NET will force you to make a choice, which is OK. 

    I made a little example that showcases our need (except it doesn't deal with selection) : http://trykendoui.telerik.com/ikId/2

    Is there a way to have kendo do this for us (aka without this ugly hack)? Removing all kind of culture-related formating would be a plausible option, if possible. 

    Thank you

    ---- 

    Copy of the "hack": 

    01.$('#numeric').on('keydown', function (e) {
    02.    if (e.which == 188) {
    03.        e.preventDefault();
    04.        caret = $(this).caret();
    05.        value = $('#numeric').val() + '';
    06.        if (value.indexOf('.') < 0 && value.indexOf(',') < 0) {
    07.            $('#numeric').val(value.substring(0, caret) + '.' + value.substring(caret));
    08.            $(this).caret(caret + 1);
    09.        }
    10.    }
    11.});


  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 25 Jun 2014 Link to this post

    Hello Jean,

    In case no culture is set the Kendo UI NumericTextBox will use dot "." as a decimal separator, and I am afraid that this is the default functionality. Currently there is no configuration option that you can set in order to tell the widget to use both dot and a comma for decimal separators. Introducing such option will not be possible as well, as it will be considered as a breaking change for a lot of the other users that rely on this exact behavior.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Jean-François
    Jean-François avatar
    26 posts
    Member since:
    Dec 2012

    Posted 25 Jun 2014 in reply to Kiril Nikolov Link to this post

    Hi,

    That's what I feared. 

    However, I have a proposition that would be backwards compatible. How about a new option, called something along the lines of "ignoreCultureOnInput" that would make use of the culture to display the number, but ignore it for input. This would allow to input 12.34 or 12,34, but have it displayed properly, according to culture. Of course the default value would have to be "false" to avoid a breaking change. 

    Is this a possibility? 

    In any case, we need this functionnality now. Is the "hack" I provided safe to use? Should we, once again, get rid of the kendo widget and go with a custom, regular textbox?

    Thanks
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 26 Jun 2014 Link to this post

    Hello Jean,

    Your suggestion seems interesting, please post it in the UserVoice section, so it will be considered for a future implementation. 

    As for your workaround - if it gives you the desired results, then I do not see a reason to go ahead and use it, as it does not use any private methods and functionalities that might change in future releases.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Jean-François
    Jean-François avatar
    26 posts
    Member since:
    Dec 2012

    Posted 26 Jun 2014 in reply to Kiril Nikolov Link to this post

    Hi, 

    I just did, thanks for your feedback. 

    For all of you finding this via google, here is the mentionned uservoice suggestion : http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback/suggestions/6102324-ignore-culture-on-input-in-numerictextbox
  7. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 26 Jun 2014 Link to this post

    Hello Jean,

    Thanks for sharing this, we really appreciate it.

    In case you have any other questions, please do not hesitate to contact us.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready