简体   繁体   English

SAPUI5:DatePicker 选择了日期,禁用了 InputField 中日期的显示

[英]SAPUI5: DatePicker chosen Date, disabled the Display of the Date in the InputField

As the Title states.正如标题所述。 The Datepicker does consist of two Elements: the Input Field and the Picking of Date(look at the Image below) Datepicker确实包含两个元素:输入字段和日期选择(请看下图)

日期选择器

You can set the Date that you would want manually, by directly accessing the ID of the DatePicker with setDateValue() and it will be automatically displayed in the Input Field.您可以手动设置所需的日期,方法是直接使用setDateValue()访问DatePicker的 ID,它将自动显示在输入字段中。

Now I want to set the Date that I want but for it to not be displayed within the Input field.现在我想设置我想要的日期,但它不会显示在输入字段中。

The thing is that I found was setVisible(false) - however this just makes the whole field disappear.问题是我发现setVisible(false) - 但这只会使整个字段消失。 What I want is simply to disable the display of the chosen date.我想要的只是禁用所选日期的显示。 How can I make it happen?我怎样才能让它发生?

You can achieve it by using Custom Data - Attaching Data Objects to Controls您可以通过使用自定义数据来实现它 - 将数据对象附加到控件

To use custom data you need to use the following namespace for the respective attributes:要使用自定义数据,您需要为各自的属性使用以下命名空间:

myNamespace="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"

XML view XML 查看

In XML view you need to include the namespace also need to use app:mySuperExtraData="CUSTTOM DATA" to attach custom data to the control.在 XML 视图中,您需要包含命名空间还需要使用app:mySuperExtraData="CUSTTOM DATA"将自定义数据附加到控件。

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.ui.commons" controllerName="my.own.controller"
  xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">
     <Button text="Click" app:mySuperExtraData="just great"></Button>
</mvc:View>

Use with Data Binding与数据绑定一起使用

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.ui.commons" controllerName="my.own.controller" 
           xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">
     <Button text="Click" app:coords="{data}" press="alertCoordinates"></Button>
</mvc:View>

JS view JS视图

By using data() we can attach data objects to controls.通过使用data()我们可以将数据对象附加到控件。

myButton.data("myData", "Hello");

Retrieve custom data检索自定义数据

myButton.data("myData")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM