我如何把OData的值传递给自定义UI5控件的属性?我尝试了这个方法,但是它没有生效。
如果我尝试将它传递给普通控件,例如<Text>
,它就有效。
如果我尝试传递静态值,它也有效:
<cc:CheckPrice valuePrice="{Price}"/> <!--❌-->
<Text text="{Price}"/> <!--✔️-->
<cc:CheckPrice valuePrice="1000"/> <!--✔️-->
如何将远程OData服务中的值传递并显示在文本控件中?
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版本:1.92