【发布时间】:2019-01-31 03:54:56
【问题描述】:
有人可以就单选按钮与 SAP UI5 的双向数据绑定提供建议。在数据模型中,我有一个名为 textType 的属性,它可以返回“Y”或“N”,基于此我必须选择对应的单选按钮
<m:RadioButton text="yes" selected="{path:'/textType',formatter: function(val){ if(textType== 'Y') return true; }else{ return false} }"/><m:RadioButton text="No" selected="{Selected}"/>
但是我无法设置该值。我尝试使用单选按钮组但没有成功
<RadioButtonGroup buttons="{/Type}" >
<RadioButton text="YES" selected = "{Selected}" />
<RadioButton text="No" selected = "{Selected}" />
</RadioButtonGroup>
有人可以就此提出建议吗?
更新模型数据代码。
var stermType = this.getView().byId("rbgTermType").getSelectedButton().getText(),
sElecReg = this.getView().byId("rbgElecReg").getSelectedButton().getText(),
sOpenReg = this.getView().byId("rbgOpenReg").getSelectedButton().getText(),
sConfirmgdpr = this.getView().byId("idConfirmgdpr").getSelected(),
oData = {};
oData = {
Term_Type: stermType,
Electoral_Reg: sElecReg,
Open_Reg: sOpenReg,
Data_Protection_Confirm: sConfirmgdpr,
};
this.getView().setBusy(true);
var that = this;
var mParams = {
success: function () {
that.getView().setBusy(false);
}.bind(),
error: function (err) {
that.getView().setBusy(false);
that.fnShowErrorMessage(jQuery.parseJSON(err.responseText).error.message.value)
}.bind()
};
this.getOwnerComponent().getModel().update( "/PassportVisaBankCitizenshipDetailsSet(StudentObjid='',PassportNumber='',AccountNumber='')", oData, mParams);
this.getOwnerComponent().getModel().refresh(true);
【问题讨论】:
-
格式化程序和表达式绑定破坏双向数据绑定。也许您需要重新设计您的 odata 后端。而不是 Y 或 N 返回布尔值。
标签: javascript data-binding odata sapui5