gpt4 book ai didi

javascript - 单选按钮组上的 SapUi5 数据绑定(bind)不起作用

转载 作者:行者123 更新时间:2023-11-28 14:29:36 24 4
gpt4 key购买 nike

有人可以就单选按钮与 SAP UI5 的双向数据绑定(bind)提供建议吗?在数据模型中,我有一个名为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);

最佳答案

您可以做的最接近的事情是将 0 视为 Y,将 1 视为 N。这是一个工作示例。 https://jsbin.com/hutuvo/edit?html,output

<!DOCTYPE HTML>
<html>

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>MVC</title>
<script id="sap-ui-bootstrap" type="text/javascript"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m,sap.ui.table"
data-sap-ui-xx-bindingSyntax="complex">
</script>

<script id="oView" type="sapui5/xmlview">
<mvc:View
controllerName="sap.example.Controller"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
height="100%">
<RadioButtonGroup selectedIndex="{/selected}">
<RadioButton text="YES" />
<RadioButton text="No" />
</RadioButtonGroup>
<Button text="Check" press="checkValue" />
</mvc:View>
</script>
<script>
sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"],
function(Controller, JSONModel) {
"use strict";

var oPageController = Controller.extend("sap.example.Controller", {
onInit: function() {
this.getView().setModel(new JSONModel({
selected: 1
}));
},
checkValue: function() {
alert(this.getView().getModel().getProperty("/selected") ? "NO" : "YES");
}
});
return oPageController;
});

var oView = sap.ui.xmlview({
viewContent: jQuery('#oView').html()
});

oView.placeAt('content');
</script>
</head>

<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>

关于javascript - 单选按钮组上的 SapUi5 数据绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52008331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com