Code Monkey home page Code Monkey logo

Comments (12)

CJayakumar avatar CJayakumar commented on September 6, 2024

Hello Team,
We are also getting the same issue with chrome (version 108.0.5359.73) and Edge browser.
The issue occurs when we do the inline edit with the grid.

Uncaught RangeError: Value , out of range for Number.prototype.toLocaleString options property useGrouping
at Number.toLocaleString ()
at Object.formatNumber (w2ui.min.js:2:7097)
at n.format (w2ui.min.js:2:363955)
at n.change (w2ui.min.js:2:364144)
at n.init (w2ui.min.js:2:353506)
at HTMLInputElement. (w2ui.min.js:2:347575)
at Function.each (jquery-3.5.1.js:381:19)
at jQuery.fn.init.each (jquery-3.5.1.js:203:17)
at b.fn.w2field (w2ui.min.js:2:347456)
at w2grid.editField (w2ui.min.js:2:126678)
formatNumber @ w2ui.min.js:2
format @ w2ui.min.js:2
change @ w2ui.min.js:2
init @ w2ui.min.js:2
(anonymous) @ w2ui.min.js:2
each @ jquery-3.5.1.js:381
each @ jquery-3.5.1.js:203
b.fn.w2field @ w2ui.min.js:2
editField @ w2ui.min.js:2
dblClick @ w2ui.min.js:2
click @ w2ui.min.js:2
(anonymous) @ w2ui.min.js:2
dispatch @ jquery-3.5.1.js:5429
elemData.handle @ jquery-3.5.1.js:5233

from w2ui.

lukemcc20 avatar lukemcc20 commented on September 6, 2024

Temporarily fixed issue by just modifying the w2ui.min.js

return parseFloat(e).toLocaleString(w2utils.settings.locale,s)}

--->
return parseFloat(e).toLocaleString()

from w2ui.

CJayakumar avatar CJayakumar commented on September 6, 2024

Thank you, It's working fine.

from w2ui.

vitmalina avatar vitmalina commented on September 6, 2024

I think the error comes from this line https://github.com/vitmalina/w2ui/blob/master/src/w2utils.js#L474. I tried to play with it and cannot repeat it.

  • What is the value you are formatting?
  • And what is your current w2utils.settings.locale?

from w2ui.

alzambo avatar alzambo commented on September 6, 2024

Hi, I have the same error in version 1.5.

At some point useGrouping value become ',' (comma) instead of a boolean and it generates the error:

function formatNumber (val, fraction, useGrouping) {
    if (val == null || val === '' || typeof val === 'object') return '';
    var options = {
        minimumFractionDigits : fraction,
        maximumFractionDigits : fraction,
        useGrouping : useGrouping  <============= HERE 
    };
    if (fraction == null || fraction < 0) {
        options.minimumFractionDigits = 0;
        options.maximumFractionDigits = 20;
    }
    return parseFloat(val).toLocaleString(w2utils.settings.locale, options);
}

I've Temporarily fixed changing from useGrouping: useGrouping to useGrouping: true and it seems working.
In my case val is 0.14 and w2utils.settings.locale is set to 'en-us'

Bye
Alex

from w2ui.

vitmalina avatar vitmalina commented on September 6, 2024

Are you sure it is the cause? I tried this in Chrome

Number(1.43e20).toLocaleString('en-US', { useGrouping: '' })

and it did not result in the error.

from w2ui.

vitmalina avatar vitmalina commented on September 6, 2024

Strangely, but I had another user report this bug with Chrome update. I have provided a fix, can you test it. Master branch has the fix and I recompiled /dis/w2ui.js

from w2ui.

vitmalina avatar vitmalina commented on September 6, 2024

Please try

from w2ui.

quillaja avatar quillaja commented on September 6, 2024

The problem is that formatNumber() is being passed "," (comma) for its useGrouping param. When this passed to toLocaleString() in options, it is not a valid value per MDN.

I'm using v1.5rc1 and suspect this bug has existed for a long time, but some recent Chrome update finally made toLocaleString() stop accepting the invalid input. Like @alzambo I just changed formatNumber() to ignore useGrouping and always use 'auto' in options.

from w2ui.

vitmalina avatar vitmalina commented on September 6, 2024

@quillaja, yes, I am aware that it was sending non boolean value for useGrouping when it only accepts booleans in new versions of Chrome. I have fixed it in both branches (1.5 and current master). Here the link to the fix: bbd9618, Now, is the new updated versions work for you?

from w2ui.

quillaja avatar quillaja commented on September 6, 2024

@vitmalina That seemed to work. Thank you.

from w2ui.

vitmalina avatar vitmalina commented on September 6, 2024

ok, then I am closing the issue

from w2ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.