sapui5 - 同时显示两次 SAPUI5 查看
问题描述
我构建了一个 sapui5 应用程序,它显示了与 SAP 工厂相关的信息。现在我需要在同一页面上显示相同的视图两次,但要显示两种不同植物的信息。想象一下像两个 iFrame。该应用程序应该能够仅使用一个视图运行(就像现在一样),并且它应该能够在同一页面上多次显示数据。
为了解决这个问题,我构建了一个额外的视图(splitview),其中包含一个组件容器来加载“真实”视图(主视图)。这以一个连续的循环结束。
这就是我尝试构建拆分视图的方式
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:l="sap.ui.layout"
controllerName="zqinsplotlist.zqinsplotlist.controller.splitview" xmlns:html="http://www.w3.org/1999/xhtml">
<App>
<pages>
<Page title="Title">
<content>
<l:HorizontalLayout class="sapUiContentPadding">
<ComponentContainer xmlns="sap.ui.core" name="zqinsplotlist.zqinsplotlist"
settings='\{ "componentData" : \{ "startupParameters" : \{"Werks" : ["1001"], "Zfcod" : ["PLOS"], "Herkunft" : ["03"] \} \}\}'/>
<Text text="Hello Split"/>
</l:HorizontalLayout>
</content>
</Page>
</pages>
</App>
</mvc:View>
我希望这将加载我的主视图一次。但它会一遍又一遍地循环调用。
解决方案
你为什么不试试…… 像这样:
<mvc:View
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:l="sap.ui.layout"
controllerName="zqinsplotlist.zqinsplotlist.controller.splitview"
xmlns:data="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
xmlns:html="http://www.w3.org/1999/xhtml">
<App>
<l:HorizontalLayout class="sapUiContentPadding">
<mvc:XMLView
viewName="zqinsplotlist.zqinsplotlist.view.MyView"
data:some="data to distinguish the views"
data:instance="1"
/>
<mvc:XMLView
viewName="zqinsplotlist.zqinsplotlist.view.MyView"
data:some="other data to distinguish this view from the above"
/>
</l:HorizontalLayout>
</App>
</mvc:View>
在 MyView 的控制器中通过 sth 区分两个视图实例。像这样:
if (this.getView().data('instance') === 1) {
// do stuff
}
那应该可以,但我还没有测试过。不能 100% 确定自定义数据适用于从 XML 实例化的视图。嗯,应该...
克里斯
推荐阅读
- c# - 在某些网络中需要代理身份验证(407)
- sql - 显示所有 IN 运算符值,状态为“可用”或“不可用”
- c# - AspNetCoreRateLimit .NET Core 3.0 - 无法解析参数 IMemoryCache 缓存
- javascript - Web 前台推送通知未弹出在 Reactjs 中使用 Firebase 集成
- c# - 如何调整这个近战脚本以提高响应速度?
- javascript - this.base 是什么意思?
- android - 如何在 android 中为 MVVM Clean 架构创建 UseCase
- pagination - 当 Antd Pagination 的 pageSize 没有设置为 10 的倍数(如 5 或 6,7,8)时,“size/page”不显示?
- r - x1 和 x2 与 z 的 3D 图,其中 z 定义为 R 中的 z = x1^2 + 0.1*x1
- c# - 是具有递归的有效通用二叉搜索树