How can I pass OData value to property of a custom UI5 control? I tried this but it's not working.
If I try passing it to normal control like <Text>
, it's working fine.
If I try passing a static value, it's working fine too:
<cc:CheckPrice valuePrice="{Price}"/> <!--?-->
<Text text="{Price}"/> <!--??-->
<cc:CheckPrice valuePrice="1000"/> <!--??-->
How can I pass the value from a remote OData service to show it like in Text control?
sap.ui.define([
"sap/ui/core/Control",
"sap/m/Label",
"sap/m/Button"
], function (Control, Label, Button) {
"use strict";
return Control.extend("zgutfiory.zguttestfiorylr.controls.CheckPrice", {
metadata: {
properties: {
"valuePrice": {
type: "string",
bindable: "bindable"
}
},
aggregations: {
"_label": {
type: "sap.m.Label",
multiple: false,
visibility: "hidden"
},
"_button": {
type: "sap.m.Button",
multiple: false,
visibility: "hidden"
}
},
events: {
// ...
}
},
init: function () {
this.setAggregation("_label", new Label({
text: "{i18n>controlCheckPrice}"
}).addStyleClass("sapUiSmallMargin"));
this.setAggregation("_button", new Button({
text: "{i18n>controlCheckPrice}",
press: [this._onSubmit, this]
}).addStyleClass("sapUiTinyMarginTopBottom"));
},
_onSubmit: function (oEvent) {
// ...
},
renderer: function (oRm, oControl) {
oRm.write('<div class="zgutCheckPriceWrap">');
oRm.write('<div class="zgutPriceWrap">' + oControl.getValuePrice() + '</div>');
oRm.renderControl(oControl.getAggregation("_label"));
oRm.renderControl(oControl.getAggregation("_button"));
oRm.write('</div>');
}
});
});
UI5 version: 1.92
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…