基于 SAPUI5 中的复选框标志激活输入字段 [英] Activating an input field based on checkbox flag in SAPUI5

查看:60
本文介绍了基于 SAPUI5 中的复选框标志激活输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据复选框标志激活输入字段.输入字段未激活.请帮忙.下面是视图和组件的片段.

I am trying to activate an input field based on the checkbox flag. The input field is not getting activated. Please help. Below are the snippets from the view and the component.

查看-------------------------------------------

View------------------------------------------

<mvc1:View
   controllerName="sap.ui.demo.wt.controller.App"
   xmlns="sap.m"
   xmlns:mvc1="sap.ui.core.mvc1">

<CheckBox id="ch1" text="Test" selected="false" select ="checkDone" enabled="true" />

<Input  id="i1" enabled="false"></Input>

</mvc1:View>

控制器--------------------------------------

Controller---------------------------------------

sap.ui.define([
                   "sap/ui/core/mvc/Controller"
                ], function (Controller) {
                   "use strict";
                   return Controller.extend("sap.ui.demo.wt.controller.App",{
                       checkDone: function (oEvent) {
                           var check = oEvent.getParameter("selected");
                            if (check === true){
                             sap.m.Input({id:"i1",
                                enabled:"true",
                                label: "Amount",
                                textAlign: sap.ui.core.TextAlign.Right,
                                value: "INR"
                             });
                           }else {
                                return "";
                           }
                        }
                   }); 
                });

推荐答案

您可以将输入字段中的 enbaled 属性绑定到复选框的模型值.然后,如果您选中该框,它应该会自动启用/禁用输入字段.

You can bind the enbaled property from the input field to the model value of the checkbox. Then if you check the box it should automatically en-/disable the input field.

像这样:

<CheckBox id="ch1" text="Test" selected="false" select ="checkDone" value="{someModel>/enabledValue}" enabled="true" />

<Input  id="i1" enabled="{someModel>/enabledValue}"></Input>

这篇关于基于 SAPUI5 中的复选框标志激活输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆