问题描述
我有一个 SAPUI5 智能表,我使用以下方法来定义 date
类型的自定义列.
I have a SAPUI5 smart table and I used the following way for defining the custom column of type date
.
在我的 oData 中,我有两列是这样的:
In my oData I have two columns like this:
<Property Name="Datum" Type="Edm.DateTime" sap:creatable="true" sap:updatable="true" sap:deletable="true" sap:display-format="Date" sap:label="Datum"/>
<Property Name="AngebotAngefragt" Type="Edm.DateTime" sap:creatable="true" sap:updatable="true" sap:deletable="true" sap:display-format="Date" sap:label="AngebotAngefragt"/>
我将其中一个定义为自定义列,如下所示:
I defined one of them as a custom column like the following:
<Column visible="true">
<customData>
<core:CustomData key="p13nData" value='{"columnKey": "Datum", "leadingProperty": "Datum", "sortProperty": "Datum", "filterProperty": "Datum", "columnIndex":"3", "type": "date"}'/>
</customData>
<Text text="{/#Meldungen/Datum/@sap:label}"/>
</Column>
在旧版本的 UI5 中,使用相同的代码片段,当我们将类型设置为 date
时,它会在 p13n
对话框中显示自定义项目的日历,但是现在我使用 1.80
版本,它显示了一个输入框.
In the older version of UI5, with same snippet of code, it showed a calendar for the custom item in p13n
dialog when we set the type to date
, but now I use version 1.80
and it shows an input box instead.
以下是 Datum
列的显示内容:
Here is what it shows for the the Datum
column:
这是我尚未定义为自定义列的 AngebotAngefragt
列显示的内容:
And here is what it shows for AngebotAngefragt
column that I haven't defined as a custom column:
推荐答案
这个语法可以解决:
<Column visible="true">
<customData>
<core:CustomData key="p13nData" value='\{"columnKey": "Datum", "leadingProperty": "Datum", "sortProperty": "Datum", "filterProperty": "Datum", "columnIndex":"3", "type": "date"}'/>
</customData>
<Text text="{/#Meldungen/Datum/@sap:label}"/>
</Column>
这里真正的诀窍是属性值中的前导反斜杠.
What really does the trick here, is the leading backslash in property value.
如果不在列 customData 定义(在 js 级别)的开头给出反斜杠,则会添加一个属性类型,但值未定义.应该与 SAPUI5 的内部处理有关(并且字符串没有被转义),但是没有明确记录.
Without giving the backslash at the beginning in the Columns customData Definition (on js level) there will be a property type added, but with value undefined. Should have something to do with the internal handling of SAPUI5 (and the String not being escaped), but however this is not explicitly documented.
代码示例:https://sapui5.netweaver.ondemand.com/#/topic/bed8274140d04bc20> (FAQ -> 1. 示例代码段)
Code Example:https://sapui5.netweaver.ondemand.com/#/topic/bed8274140d04fc0b9bcb2db42d8bac2 (FAQ -> 1. Example Snippet)
这篇关于SAPUI5 未对 Smart Table 中的自定义列使用正确的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!