numberFormat doesn't work for text editor in property view

https://snippet.webix.com/bydevuus

Tried different approaches but ended with my own editor, extended from webix.editors.text

  • format: webix.i18n.numberFormat - when you put number with comma as decimal point it format field without decimal part. 1,25 becomes 1,00 [or 1.00 - depends on locale], my locale is pl-PL so we have comma using numeric Keypad on the keyboard
  • numberFormat: “1 111,00” - doesn’t work totally
  • myOwnEditor - it’s HTML5 number type - doesn’t format anything
  • myOwnEditor + format: webix.i18n.numberFormat - works OK

Should it be like that?
According to:
https://docs.webix.com/desktop__editing.html#text
numberFormat:“1’111.00” should format text editor.

Hello @Jacekk015 ,

numberFormat: “1 111,00” - doesn’t work totally
Unfortunately, property view doesn’t support such functionality

As a solution, you can use datatable view and write a conditional template
or create a format by your own self (custom formatting)
Information about format is here.

Here is an example how works numberFormat in datatable: Code Snippet

Another example of how we can use format: https://snippet.webix.com/h7dm157j

Thanks

I’ve ended in custom function which parse value using current locale:
https://snippet.webix.com/azj660hg

The problem is that when you set in editor object
format: webix.i18n.numberFormat
value isn’t parsed.
webix.i18n.numberFormat looks like it’s prepared for JSON only and there you always have a dot.
User input always need to be parsed, that’s why webix.i18n.numberFormat isn’t enough.
So my function firstly parses value to ~JSON number and then back to locale number.

https://snippet.webix.com/a12oo85n

Switched back to custom editor. Looks and feels nicer, and it’s global through whole Webix app. Works with locale, even cuts value to locales decimalSize.
Only drawback is, that when you will get the value and try to send it to your backend you will probably need to parse it to float using webix.Number.parse again.

Hi @Nastja

“Here is an example how works numberFormat in datatable: Code Snippet

This not running on webix 5.4.2 pro webix.js file ( running well with debug file)

and not running at all with 5.2.3 pro versions ( debug or not )

“format” method run well