Skip to Content
avatar image
Former Member

Field format is changing from number to text

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Jan 17, 2017 at 03:23 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 17, 2017 at 04:43 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 18, 2017 at 06:35 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 18, 2017 at 06:35 PM

    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

    Add comment
    10|10000 characters needed characters exceeded