Reputation: 3
I'm reading a tutorial about data binding syntax (SAPUI5). Here is an example of data binding to an oData model:
<Input value="{
path: '/number',
type: 'sap.ui.model.type.Integer',
formatOptions: {
minIntegerDigits: 3
},
constraints: {
maximum: 1000
}
}"/>
So, the question is: what those "path", "type", "formatOptions", "constraints" stand for? I mean, I realize - these are some binding attributes. The value property of the Input control is a string. So, the binding attributes will be parsed and interpreted somewhere inside of the control, but they are not semantically a part of the control. So, is it some oData syntax/attributes, or what? And do you know where can I get all the possible options here?
Upvotes: 0
Views: 2312
Reputation: 840
Depending on the given type, different constraints and format options are possible. In your case, the type is integer/number.
Possible parameters for a general property binding are defined in the abstract class sap.ui.base.ManagedObject.
Possible constraints and format options for an Integer type are defined in the class sap.ui.model.type.Integer.
Possible format options for a number (and also for an integer) are defined in the class sap.ui.core.format.NumberFormat.
Upvotes: 1
Reputation: 581
Property binding allows properties of the control to get automatically initialized and updated from model data.
To define a property binding on a control, the following two options exist:
Once you have defined the property binding, the property is updated automatically every time the bound model property value is changed.
The most convenient way to define a property binding, which is sufficient in most cases, is to include the binding path within curly brackets as a string literal in the settings object:
var oTextField = new sap.ui.commons.TextField({
value: "{/company/name}"
});
Alternatively (I think this is what you asked), you can use an extended syntax for property bindings. This extended syntax allows you to define additional binding information to be contained in the settings object, such as a formatter function. In this case you use a JS object instead of a string literal. This must contain a path property containing the binding path and can contain additional properties:
var oTextField = new sap.ui.commons.TextField({ value: { path: "/company/name", mode: sap.ui.model.BindingMode.OneWay, formatter: .myFormatterFn } }); this will trigger the myFormatterFn function on your controller and the returned value will be attached to the textFiled.
while the different types can be one of the following:
sap.ui.model.type.Boolean
This class represents boolean simple types.
sap.ui.model.type.Currency
This class represents the currency composite type.
sap.ui.model.type.Date
This class represents date simple types.
sap.ui.model.type.DateInterval
This class represents the Date interval composite type.
sap.ui.model.type.DateTime
This class represents datetime simple types.
sap.ui.model.type.DateTimeInterval
This class represents the DateTime interval composite type.
sap.ui.model.type.FileSize
This class represents file size simple types.
sap.ui.model.type.Float
This class represents float simple types.
sap.ui.model.type.Integer
This class represents integer simple types.
sap.ui.model.type.String This class represents string simple types.
sap.ui.model.type.Time
This class represents time simple types.
sap.ui.model.type.TimeInterval
This class represents the Time interval composite type.
sap.ui.model.type.Unit
This class represents the Unit composite type.
You can generate the following parameters for each SimpleType in the constructor:
format options: Format options define how a value is formatted and displayed in the UI.
constraints: Constraints are optional and define how an input value entered in the UI should look like. During parsing the value is validated against these constraints. For example, a String type has a constraint for maxLength and minLength which are automatically validated when parsing the input values.
Please check this doc , it might put some light on your questions
Upvotes: 0