从 UI5 控制器中按下的列表项获取绑定值
Get bound values from pressed List Item in UI5 controller
我是 SAP Fiori (UI5) 的初学者,正在尝试从 SAP Web IDE 中使用 sap.m.Table
制作的 table 中检索值。但我没有成功。有人提示如何到达那里吗?
<Table id="table0" items="{/Entity1_Set}">
<ColumnListItem detailPress=".onShowHello" type="DetailAndActive">
<Text id="text5" maxLines="0" text="{Id}" />
<Text id="text6" maxLines="0" text="{field1}" />
<Text id="text7" maxLines="0" text="{field2}" />
<Text id="text8" maxLines="0" text="Euro"/>
</ColumnListItem>
<columns>
<Column id="column0">
<Label id="label0" text="Floor"/>
</Column>
</columns>
</Table>
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageToast",
], function(Controller, MessageToast) {
"use strict";
return Controller.extend("QuickStartApplication.controller.View1", {
onShowHello: function(){
MessageToast.show("Hello World!");
},
});
});
在“hello world”-MessageToast 中,我想显示 table 中字段的值。
您可以在事件中调用的函数中传递参数。
另请参阅 https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ListItemBase.html#event:detailPress
使用这些参数,您可以访问绑定数据。
请参阅以下代码了解如何读取 ColumnListItem
:
的绑定上下文
detailPress : function(oEventParams){
var oListItem = oEventParams.getSource();
var oBindingContext = oListItem.getBindingContext(); var sSomePropertyValue = oBindingContext.getProperty("<nameOfProperty>"); }
使用 .getProperty
,您可以访问您的字段值。
我是 SAP Fiori (UI5) 的初学者,正在尝试从 SAP Web IDE 中使用 sap.m.Table
制作的 table 中检索值。但我没有成功。有人提示如何到达那里吗?
<Table id="table0" items="{/Entity1_Set}">
<ColumnListItem detailPress=".onShowHello" type="DetailAndActive">
<Text id="text5" maxLines="0" text="{Id}" />
<Text id="text6" maxLines="0" text="{field1}" />
<Text id="text7" maxLines="0" text="{field2}" />
<Text id="text8" maxLines="0" text="Euro"/>
</ColumnListItem>
<columns>
<Column id="column0">
<Label id="label0" text="Floor"/>
</Column>
</columns>
</Table>
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageToast",
], function(Controller, MessageToast) {
"use strict";
return Controller.extend("QuickStartApplication.controller.View1", {
onShowHello: function(){
MessageToast.show("Hello World!");
},
});
});
在“hello world”-MessageToast 中,我想显示 table 中字段的值。
您可以在事件中调用的函数中传递参数。 另请参阅 https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ListItemBase.html#event:detailPress
使用这些参数,您可以访问绑定数据。
请参阅以下代码了解如何读取 ColumnListItem
:
detailPress : function(oEventParams){
var oListItem = oEventParams.getSource();
var oBindingContext = oListItem.getBindingContext(); var sSomePropertyValue = oBindingContext.getProperty("<nameOfProperty>"); }
使用 .getProperty
,您可以访问您的字段值。