Specific number of decimal places to 3 during edition

Tags: #<Tag:0x00007f0b033e45d0>

Hello,

I would like to know if it is possible to define a limit of decimal numbers during edition in a table.
This is more or less the code that I am using to show the grid:

  {
    data: 'name',
    type: 'text',
  }, {
    data: 'Currencyfactor',
    type: 'numeric',
    renderer: this._currencyRenderer,
    numericFormat: {
      pattern: '00,000',
    },
  },
];
return columnDefinitions;

As you see, I am setting the numbers of decimals in the numericFormat attribute and it works great, but I would like to avoid the users type more than 3 decimals. Is it possible to do it?

Thank you :wink:

Hi @jlsuarezcabrera

welcome on our forum :slight_smile:

That’s a good question. We can surely round the value once the editor closes http://jsfiddle.net/073d65bk/ but in your case everything needs to be done within the editor.
I guess that you can work on this example https://jsfiddle.net/1nrb5was/
Line 32 describes the length of the textarea. The remaining step would be to track the comma/dot and then change the maxlength accordingly to the number of digits before the comma/dot.

Would that meet the goal?

1 Like

Hey @jlsuarezcabrera

how’s the progress with Handsontable?

1 Like

Thank you Aleksandra!

This is what I was looking for :wink: https://jsfiddle.net/1nrb5was/

Great :slight_smile:

I’m closing the topic.

Let me know if you’d need anything.