简体   繁体   English

fiori 启动板中的稳定 ID

[英]Stable ID's in fiori launchpad

I am using a FlexColumnLayout for my app.我正在为我的应用程序使用 FlexColumnLayout。

In the mid column I need to access a controll of the begin column of the FlexColumnLayout.在中间列中,我需要访问 FlexColumnLayout 的开始列的控件。 Here is the problem:这是问题所在:

Since it is a different view I cannot use由于它是一个不同的视图,我不能使用

this.getView().byId("myId")

My first solution was to use stable ID's, by giving the views (XML) IDs.我的第一个解决方案是通过提供视图 (XML) ID 来使用稳定 ID。 Like that I could use:像那样我可以使用:

sap.ui.getCore().byId("application---viewId--myId")

At first it worked just fine, but now that I integrated my app into the fiori launchpad the first part of the stable ID (the part before "viewId") changed and when I transport into productive it will change again.起初它工作得很好,但现在我将我的应用程序集成到 fiori 启动板中,稳定 ID 的第一部分(“viewId”之前的部分)发生了变化,当我进入生产状态时,它会再次发生变化。

Is there a way to access the mid column controls without sap.ui.getCore().byId?有没有办法在没有 sap.ui.getCore().byId 的情况下访问中间列控件? Or is there a way to load the first part dynamically so I don't need to change my IDs when tranporting?或者有没有办法动态加载第一部分,这样我就不需要在传输时更改我的 ID?

Sadly I don't know how to reproduce a Launchpad for testing purposes, but for those who want to test their ideas about my problem, my FlexColumnLayout is build just like in the DemoApp: https://sapui5.hana.ondemand.com/#/entity/sap.f.FlexibleColumnLayout遗憾的是,我不知道如何为测试目的重现 Launchpad,但对于那些想要测试他们对我的问题的想法的人,我的 FlexColumnLayout 就像在 DemoApp 中一样构建: https ://sapui5.hana.ondemand.com/ #/entity/sap.f.FlexibleColumnLayout

Ok guys i found a solution:好的,我找到了一个解决方案:

this.getView().getParent().getParent()

returns the FlexColumnLayout.返回 FlexColumnLayout。 This has a method called "getBeginColumnPages", which returns an array of the views representing the begin column.它有一个名为“getBeginColumnPages”的方法,它返回一个表示开始列的视图数组。 Now that i can access the view in which my control is found, i can access it with the sap.ui.core.mvc.View.byId() method.现在我可以访问找到我的控件的视图,我可以使用 sap.ui.core.mvc.View.byId() 方法访问它。

Now I have我现在有

this.getView().getParent().getParent().getMidColumnPages()[0].byId("myId")

Since the doulbe .getParent() doesn't seem to be ideal, please post a better solution if you know one : D由于 doulbe .getParent() 似乎并不理想,如果您知道,请发布更好的解决方案:D

您必须使用createId()函数,这将返回控件的完整 ID。

this.byId(this.createId("myid"));

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

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