Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

sapui5 - Synchronize Input with Slider values independent from locales

This is a follow-up question to How to bind integer Input value to Slider.

I have found out that the demo solution in this answer only works when there are integer values in the slider and the language of your browser is set to English.

Snippet from the demo:

<Input xmlns="sap.m"
  xmlns:core="sap.ui.core"
  core:require="{FloatType: 'sap/ui/model/type/Float'}"
  type="Number"
  value="{
    path: '/value',
    type: 'FloatType'
  }"
/>

To reproduce the issue:

  1. Go to the settings of your browser.
  2. Set e.g. German as the language.
  3. Reload the demo.

If the step of the slider is then set to an integer value (e.g. 1), values are all shown correctly in the input field.
With step="0.1", however, only integer values are shown whereas float values (e.g. "1,4") are hidden, causing warning in the browser console:

The specified value "1,4" cannot be parsed, or is out of range.

Any ideas or better solutions?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In that case, remove type="Number" from the <Input> control.

The property type="Number" in UI5 shouldn't be used together with value-binding anyway, due to browsers implementing HTML <input type="number"> behavior slightly differently, according to the API reference:

Only the default value sap.m.InputType.Text may be used in combination with data model formats. (Source).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...