Why do Numeric Editor return string values

Tags: #<Tag:0x00007fa98dff8eb0>

I have my datatype definition as follow and I am loading all numeric values

cellTypes.registerCellType('int', {
  editor: Handsontable.editors.NumericEditor,
  renderer: Handsontable.renderers.NumericRenderer,
  className: 'htRight',
  numericFormat: {
    pattern: '0,0.00',
  }
})

but when I check type of valueAfter change in afterchange callback it returns me the string and creates the problem on server-side sorting. How can I make it return numeric values?

Hi @chunnumunnu99

By default, Handsontable treats all cell values as string type. This is because returns a string as its value.

So in afterChange, you have to change string to number. For example:

afterChange: (changes) => {
    changes.forEach(([row, prop, oldValue, newValue]) => {
      Number(newValue);
    });
  }

thank you @piotr.nowak. checking datatype and parsing value according to data type on every change is not appealing solution to me. Is there a way to specify this in column/datatype definition ?

Maybe you could collect in the array and after some amount of array you use Number(newValue);.

Unfortunately, Handsontable treats all cell values as string type so even if you specify the column as a numeric type the cell value is still treated as a string.