0

Is it possible to have custom formater in inline edit cell? Well, this is my column formatter:

formatoptions: { decimalPlaces: 4, decimalSeparator: ",", thousandsSeparator: ".", defaultValue: " " }

Main problem is that separator in inline mode is "." and not "," and if user enters "242151,456" it returns 'NaN' but "25675.466" it is transfered in corresponding format. Need help :)

Darman
  • 71
  • 1
  • 3
  • 12

1 Answers1

1

There are different ways to do this. For example you can modify the data entered by the user inside of saveRowValidation callback. For example, the demo https://jsfiddle.net/OlegKi/kj8y2nu9/ uses

saveRowValidation: function (options) {
    var newData = options.newData;
    newData.amount = String(newData.amount).replace(",", ".");
    newData.tax = String(newData.tax).replace(",", ".");
    newData.total = String(newData.total).replace(",", ".");
    return true; // validation is successful
}

to replace , to .. The exact logic could be a little complex, but I think you could implement it inside of saveRowValidation in the same way.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Yes. It's a good starting point and I will have to cover many cases. And I suppose that I can set that user can only enter numbers and separators in cell while inline editing? Thank you so much Oleg! :) – Darman Dec 12 '17 at 09:39
  • @Darman: You are welcome! You can bind `keypress` used during editing and filter some keys. The old demo https://stackoverflow.com/a/4407958/315935 uses searchoptions instead of editoptions, but it works at the same way. It allows only digits, dot and comma and replace comma to dot during typing. It should be close to your requirements. – Oleg Dec 12 '17 at 09:47