Skip to Content
0

Field format is changing from number to text

Jan 17, 2017 at 01:09 PM

77

avatar image

Hi Friends,

in sap.m.table I have a number field. As long it is not touched it stays a number. But when I change it, it becomes a string. Is this normal or can I avoid it in any way?

Thanks Joerg

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Sergio Guerrero Jan 17, 2017 at 03:23 PM
0

is your control (number field) a text control? an input control? you could probably force it by using a liveChange event and then running on a formatter function

Share
10 |10000 characters needed characters left characters exceeded
joerg arndt Jan 17, 2017 at 04:43 PM
0

Hi Sergio,

it is sap.m.Input with Number format.

In Model under properties I can see the Format is number but the value is changed string like "786". I have function "change" to update a chart. Where I can parse it to number. I managed it once to change the chart while change the values by hand. But I can not make agen.

I tried it like this.

var newValue = parseInt(oEvent.mParameters.newValue);
var oField = sap.ui.getCore().byId(fieldId);
oField.setValue(newValue);

or

var oChartModel = sap.ui.getCore().getModel("CHARTMODEL");
var chartdata = oChartModel.getData();
chartdata.results[0].SEATSMAX = newValue;
oChartModel.setData(chartdata);
oChartModel.refresh();

Both, the chart is not updated.

How is it possible that the value in the Model is changed to string.

I have the same propblem when I want to save data to database. But here I can convert it back to number.

Share
10 |10000 characters needed characters left characters exceeded
VIPLOVE KHUSHALANI Jan 18, 2017 at 06:35 AM
0

Hi Joerg Arndt,

Actually when we bind the property of a control , we have data type for that binding (sap.ui.model.type.<String/Float/Integer..>). I think you need to set that as Integer.

Check out this link for Data Types.

Thanks

Viplove

Share
10 |10000 characters needed characters left characters exceeded
joerg arndt Jan 18, 2017 at 06:35 PM
0

Thanks Viplove,

but sap.m.table expecting sap.m.input and furthermore number, email etc.

But at least, now it works when I parse the string in "change" event and set true in refresh.

oChartModel.refresh();

now.

oChartModel.refresh(true);

Rg. Joerg

Share
10 |10000 characters needed characters left characters exceeded