Skip to Content
avatar image
Former Member

BOOLEAN oData value is coming as string in UI5?

Hi,

My requirement is to bind editable property of a field in table to JSON model so that the field will be editable depending on oData Model. Now, the value of EDIT_FLAG is coming as Boolean in SAP Gateway, but when I try to consume the same in UI5, in the Model it is coming as string value. So when I am binding it to Input field its showing as '"false" is of type string, expected boolean for property "editable" of Element'

In OData, below is the screen shot:

odata.jpg

But in UI5 it is coming as string

ui5.png

Thanks,

Venkat.

odata.jpg (17.4 kB)
ui5.png (8.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 22, 2017 at 06:02 PM

    Use a formatter.

    Ex:

    // Binding in the view
    
    state="{ path: 'EDIT_FLAG', formatter: 'getBooleanValue' }"
    
    // Formatter function
    getBooleanValue: function(EDIT_FLAG){
    
    var booleanVal = (EDIT_FLAG === "true");
    
    return booleanVal;
    
    }
    Add comment
    10|10000 characters needed characters exceeded