How to change numeric format dynamically?

Tags: #<Tag:0x00007efc64e75470>

Hello,

I would like to change numericFormat for cell dynamically but I don’t know exact syntax how to do it. I used

hot.setCellMeta(1, 1, 'type', 'numeric');
hot.setCellMeta(1, 1, 'numericFormat', "pattern: '€0.00', culture: 'sk-SK'");

Example at
https://jsfiddle.net/janzitniak/mdjofgnc/7/
Jan

Hi @jan.zitniak

setCellMeta has a 4 parameters - row, column, key, value - https://handsontable.com/docs/7.4.2/Core.html#setCellMeta
Your demo doesn’t work because we don’t have a numericFormat as a key.

In your case, the better option is a setCellMetaObject which has a 3 param row, column, prop. Prop is an object - https://handsontable.com/docs/7.4.2/Core.html#setCellMetaObject

So, with it in mind here is a working demo - https://jsfiddle.net/5y17d2wm/

Dear @piotr.nowak thank you for your right answer and real example.
I would like ask you again - how to change numeric format to €, because I used

  numericFormat: {
    pattern: '0,0.00 $',
    culture: 'de-DE' // use this for EUR (German),
    // more cultures available on http://numbrojs.com/languages.html
  }

according to documentation at https://handsontable.com/docs/7.4.2/demo-numeric.html and it doesn’t work, my jsfiddle available at https://jsfiddle.net/janzitniak/07bgz2j8/11/

Hi @jan.zitniak

You have to attach the numbro component itself.
Here is an updated demo - https://jsfiddle.net/ax8co4Lb/

1 Like

Hi @piotr.nowak,

thanks again for your right answer.

Thanks.
So I close this thread.