[GH #5645] Numeric Format Pattern issue whole units display as 0.00 and not 0

Tags: #<Tag:0x00007f8b285b8e10> #<Tag:0x00007f8b285b8cd0>

Hi

I’ve upgraded from an earlier version of handsontables

I have an issue where I can’t display units with out decimal places, please could you help; without editing the input value, too a number without decimal places.

numericFormat: {
pattern: ‘0,0’,
culture: ‘en-GB’
},

http://jsfiddle.net/j21f4bso/

Kind Regards

Ben Warren

Welcome Ben.

If you wish to show rounded numbers but keep the decimals you can create a custom renderer.

Here’s an example that you can use http://jsfiddle.net/zjqr3p7b/

  1. I have deleted the numericFormat and added renderer: myRenderer to the first column settings
  2. created the myRenderer function, which is my new renderer

Let me know if it meets your requirements.

Hi aleksandra_budnik

I was using handsontable 1.14.2 this allowed a format of ‘0,0’ , I have a table full of formats for different columns that are read via an API call. This is something I would not of expected to change. Isn’t this a handsontable bug. This will mean I have to hack about with the code inserting and removing

columns: [{
data: ‘Units’,
type: ‘numeric’,
renderer: myRenderer
},
etc…

Kind Regards

Ben

Not so long time ago Numbro, the library that we use to handle numeric cell type, has upgraded to v 2.0. Now, when you want to round a number you use

mantissa to round it up https://jsfiddle.net/rabq614y/
(I do not see anything that can be used to round it down but I have asked our developer to check it)

Release notes for the 4.0.0 version which introduced the changes https://handsontable.com/docs/4.0.0/tutorial-release-notes.html

I have left myself a note to create some tutorials on that subject and share on the blog or in the docs. Thanks for spotting that. It is hard to find, especially for devs who update the library and suddenly it does not work.

Hi

This change seems to work, except now when entering a value such as 750220.55 becomes 750K, which isn’t ideal, especially when the values has already been rounded up by 1000.

https://jsfiddle.net/rabq614y/3/

numbro seem to have a issue listed, but this doesn’t fix my problem in handsontable. they use ‘0a’ with the same k issue.
they suggested example using: numbro(132324.52345).format({mantissa:0}), which doesn’t seem to work with handsontable ie pattern = ''mantissa:0".

Kind regards

Ben

You are right, Ben. It should be much easier to set those values.
I’ve created a feature request on our Github board https://github.com/handsontable/handsontable/issues/5645

Please could you let me know what is happening with this. Has it been fixed. There should also be a breakage report in your git code report from “1.15.0”

Hey @ben.warren

It hasn’t been added yet. Please track changes to https://github.com/handsontable/handsontable/issues/5645
Once it is done you’d get a notification about the milestone and when it gets released then in the release panel

now the release and milestone panels are empty

Hey @ben.warren

I just wanted to share an update. You can call

numericFormat: {
  pattern: {
    mantissa: 0
  },
}

not sure if we mentioned this in other emails but I wanted to update this topic.

Hi,

Thank you.

I Have created my own fix at the moment but will try this when I can update to 7+. Having issues with 7 mentioned on another ticket so stuck on 6.22, but would be good to use your fix at some point.

Kind Regards

Ben

Hi Aleksandra,

I had same issues, my company will be upgrading and we tried updating to 7.0 and found some of the old 1.xx code was invalid; we had set our numeric columns to precision of 3, now it’s broken. The numericFormat entry in your docs section does not correctly describe current syntax. And going to numbro site doesn’t give a straight ahead explanation either. Can you update the numeric format entries to list all correct properties and expected values?

thanks, Pavel

Hey Pavel,

can you share the input/output data? Do you convert them on the initialization? Is the edited value and rendered value differ?

Agreed, the documentation on number formatting needs some serious updating, it took me way too long to find this post. And as Pavel mentioned, the numbro documentation is not directly applicable to hot.

Hey @e-h

What exactly did you miss in the docs? We are open for all the suggestions.

Well, the pattern shown in the doc is incorrect. To hide decimals for instance, it’s now
type: ‘numeric’,
numericFormat: {
pattern: { mantissa: 0 }
}

As Pavel said, it would be nice to have examples showing how the various formatting options available in numbro can be used in hot, like thousandSeparated, spaceSeparated etc.

Hm… the

{
        type: 'numeric',
        numericFormat: {
          pattern: {
              mantissa: 1
          }
      }
 }

seem to work just fine http://jsfiddle.net/t87hur3s/

It might not be working at all (in older versions) but since 7.0.0 it works like this all the time.

examples showing how the various formatting options available in numbro can be used in hot, like thousandSeparated, spaceSeparated etc.

I agree. I will mention this subject to our Tech Writer - we might alter the docs or create a tutorial blog post.

Aleksandra, your example works fine, but the documentation doesn’t use this syntax:
https://handsontable.com/docs/7.4.2/demo-numeric.html

I have already reported the need to changes and additional examples to our Tech Writer. Thank you for the feedback @e-h