-1

I am trying to call a control of the master view from the detail view controller. If I do it like this I am able to get the list data

sap.ui.getCore().byId("application-Test-url-component---master--list")

if i do it like this I am not able to get the list

sap.ui.getCore().byId("list").

Is this the correct way to call if any version changes

sap.ui.getCore().byId("application-Test-url-component---master--list")

Please provide suggestions or any links.

Voyager
  • 820
  • 4
  • 11
deva
  • 27
  • 1
  • 8
  • 1
    Try this: https://stackoverflow.com/questions/37187748/what-is-the-eventbus-in-sapui5-for just write a data provider methode in the controller the data is from – Erch Sep 23 '19 at 08:41
  • in bTob, there is almost no use case for this. Usually you can handle things over routing. Why would you like to do this? – Benedikt Kromer Sep 25 '19 at 08:05
  • Thank you bkr using router i able to get the data – deva Sep 25 '19 at 17:57

1 Answers1

0

First of all, do not use the byId(...) method on the Core, it's bad practice and not a good habit to get into.

For your interest, the reason your first line of code does find the relevant UI control, but the second line does not, is because the Core is shared across all applications in the Fiori Launchpad. This means that all Control IDs are prefixed with the application namespace, and because your second line of code does not contain the application namespace it therefore does not find the Control.

As for how to correctly get the List data from that Control from elsewhere, simply get the bound data from the same model path you're binding that Control to. For example, if the Master list is bound to {/Products} then you get the same data by this.getView().getModel().getProperty("/Products"). This assumes that your data model is shared across the application however. I would recommend that you read the UI5 documentation and understand more about MVC architecture, because the UI Controls should just surface the data which is stored in the underlying Model(s) and that is where the data should be.

Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
jbm1991
  • 98
  • 1
  • 7