If I use this.getView()
inside the controller of a view I can retrieve it without problems.
How can I retrieve the view if I am outside the controller (e. g. in controller of another view)?
I try sap.ui.core.Core().byId("<name of view>")
but it returns undefined
.
How do I return a view from a controller? To return a view from the controller action method, we can use View() method by passing respective parameters. return View(“ViewName”) – returns the view name specified in the current view folder (view extension name “. cshtml” is not required.
To create a partial view, right click on the Shared folder -> click Add -> click View.. to open the Add View popup, as shown below. You can create a partial view in any View folder. However, it is recommended to create all your partial views in the Shared folder so that they can be used in multiple views.
Yes, put the view in shared folder. This will automatically make view available across multiple controllers.
You can instantiate another view using:
var view = sap.ui.jsview("<name of view>");
If you´re using different view types you can choose the necessary function from here.
To avoid multiple instantiation you could do something like this:
var view = sap.ui.getCore().byId("id");
if (view === undefined) {
view = sap.ui.jsview("id", "<name of view>");
}
See this for more details regarding view definition/instantiation and IDs.
When I create a view i set a id
var theView=sap.ui.xmlview("OperationDetail, "<name of view>");
then i retrieve it by id
var theView = sap.ui.core.Core().byId("OperationDetail");
var myPage=theView.byId("pageOperation");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With