Openui5 Binding Property With A Function, Instead Of Direct Access
I would like to bind a property (flag_baz in this case) from a JSONModel to a checkbox. Thing is that the json model looks like this. { foo: 'Foo', bar:'Bar', flag_baz : 'X
Solution 1:
Well in case some cares i've found the answer on my own.
All bindings can use a type like so
checkBox.bindProperty("checked", {
path : "flag_baz",
type : new BooleanStringType()
});
the BooleanStringType class would look like this:
sap.ui.model.SimpleType.extend("BooleanStringType", {
//called when going from model to ui
formatValue : function(flag_baz){
return flag_baz === "X";
},
//called when going from ui back to the model
parseValue : function(flag_baz){
return flag_baz ? "X" : "";
},
validateValue : function(flag_baz){
//some validation if needed
}
});
Post a Comment for "Openui5 Binding Property With A Function, Instead Of Direct Access"