[英]Table Header Not Visible in UI5 Application
我已经创建了一个表,但是标题没有显示。 在组件内部,我正在读取一个OData实体并将其存储在JSON模型中。 然后,此JSON模型用于绑定标题列文本。
我已附上表格输出图像以供参考:
标题View.xml:
<mvc:View controllerName="NPAWRMA.controller.header" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m" xmlns:l="sap.ui.layout">
<App id="idAppControl">
<pages>
<Page title="NPAW RMA Report">
<content>
<l:VerticalLayout>
<Table id="table" growing="true" items="{odata>/RmaPercRevColSet}">
<columns>
<Column>
<Text text="CBU" id="CbuShortNameColumnTitle"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label01}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label02}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label03}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label04}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label05}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label06}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label07}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label08}"/>
</Column>
</columns>
<items>
<ColumnListItem type="Active" press="onPress">
<cells>
<Text text="{odata>CbuShortName}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc01', formatter: '.formatter.numberUnit' }" state="{State01}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc02', formatter: '.formatter.numberUnit' }" state="{State02}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc03', formatter: '.formatter.numberUnit' }" state="{State03}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc04', formatter: '.formatter.numberUnit' }" state="{State04}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc05', formatter: '.formatter.numberUnit' }" state="{State05}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc06', formatter: '.formatter.numberUnit' }" state="{State06}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc07', formatter: '.formatter.numberUnit' }" state="{State07}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc08', formatter: '.formatter.numberUnit' }" state="{State08}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc09', formatter: '.formatter.numberUnit' }" state="{State09}"/>
</cells>
</ColumnListItem>
</items>
</Table>
<Table id="table1" growing="true" items="{odata>/RmaPercRevColSet}">
<columns>
<Column>
<Text text="CBU" id="CbuShortNameColumnTitle1"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label01}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label02}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label03}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label04}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label05}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label06}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label07}"/>
</Column>
<Column>
<Text text="{Labels>/Labels1/Label08}"/>
</Column>
</columns>
<items>
<ColumnListItem type="Active" press="onPress">
<cells>
<Text text="{odata>CbuShortName}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc01', formatter: '.formatter.numberUnit' }" unit="%" state="{State01}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc02', formatter: '.formatter.numberUnit' }" unit="%" state="{State02}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc03', formatter: '.formatter.numberUnit' }" unit="%" state="{State03}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc04', formatter: '.formatter.numberUnit' }" unit="%" state="{State04}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc05', formatter: '.formatter.numberUnit' }" unit="%" state="{State05}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc06', formatter: '.formatter.numberUnit' }" unit="%" state="{State06}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc07', formatter: '.formatter.numberUnit' }" unit="%" state="{State07}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc08', formatter: '.formatter.numberUnit' }" unit="%" state="{State08}"/>
<ObjectNumber number="{ path: 'odata>NpiPerc09', formatter: '.formatter.numberUnit' }" unit="%" state="{State09}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</l:VerticalLayout>
</content>
</Page>
</pages>
</App>
</mvc:View>
Component.js:
sap.ui.define([ "sap/ui/core/UIComponent", "sap/ui/Device", "NPAWRMA/model/models" ], function(UIComponent, Device, models) { "use strict"; return UIComponent.extend("NPAWRMA.Component", { metadata: { manifest: "json" }, /** * The component is initialized by UI5 automatically during the startup of the app and calls the init method once. * @public * @override */ init: function() { //"Access-Control-Allow-Origin: *.local.com"; //"Access-Control-Allow-Headers: X-KEY"; UIComponent.prototype.init.apply(this, arguments); debugger; var sModel = this.getModel("odata"); sModel.setSizeLimit(999); var oJson1 = new sap.ui.model.json.JSONModel(); sModel.read("/Labels1Set('0')", { success: function(oss) { oJson1.setData({ Label: oss }); }, error: function(oss) {} }); this.setModel(oJson1, "Labels"); // enable routing this.getRouter().initialize(); // set the device model this.setModel(models.createDeviceModel(), "device"); } }); });
在您的屏幕快照中,表标题实际上已显示。 第一列标题(已静态绑定)正确呈现。
因此,问题似乎在于绑定路径或模型内容本身。 我不确定您在sModel.read("/Labels1Set('0')", ...)
成功回调中获得了什么,因为它完全取决于您如何定义OData模型。 您应该检查是否确实具有所有这些Label01
至Label08
属性。
我能发现的另一件事情是,你实际上是设置在结果/Label
绑定路径,但你使用的是/Labels1/LabelXX
绑定路径(即路径的开头Labels1
而不只是Label
)。 要解决此问题,您应该调整read调用的成功回调:
success: function(oss) {
oJson1.setData({
Labels1: oss
});
}
或者,也许更具可读性的是只执行oJson1.setData(oss)
然后从绑定路径中删除/Labels1
前缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.