cancel
Showing results for 
Search instead for 
Did you mean: 

how create a view (pages in Splittapp) dynamically after Request?

Former Member
0 Kudos

hi,

i have a index.html where there is only the div container.

then i have a view, which is placed at the container.

then i have a controller where i have a request to the backendserver.

the request sends me  a structure, which i have to use for create the splittapp in the view (navigation, pages, ..).

the problem is, that the view is initialized before the controller is, so i cannot use the function in the controller to get data, and create in the view the controls dynamically.

does someone has a solution or the same problem?

br Alex

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member254395
Active Participant
0 Kudos

Hi Alex,

In the view better use bind property, this will bing the model to your controlls. So when you made any call to the back-end systems through odata etc... after that bind the model to the control like below

In view I  have a label like this

new sap.ui.commons.TextView("dept1",{}).bindProperty("text", "flightDetails/airportFrom");

In modle  after odata call i will bind teh model to this as,

sap.ui.getCore().byId("dept1").setModel(flightCollectionModel);

Thanks & Regards

Rabin D.

Former Member
0 Kudos

hi,

thanks for your answer. yes ok this is correct, but i don't want to bind propertys, i need the data from backend, to create the app.

so for example i got from the backend: 3 root elements, and every root element got a child, and each child got a "view".

i have a splitapp and want to tell : make 3 listitems in the masterpage, make a child listitem for each. and if you click on a child element, show a page in the detailpage.

this is only a example, because the "menulist" from the backend is customizable.

br Alex

former_member254395
Active Participant
0 Kudos

Hi Alex,

I got your app design, first design all the views. As you told we wont get any data on the view  because controller will be called after view rendering only . So better made all back-end calls in do-init of the controller js and do data binding in the  onAfterRendering method .  This method will called after loading the view only.

I hope this will give u an idea. As we can have more modes in single application.

Rabin D

Former Member
0 Kudos

hi rabin,

how it is possible, to create the content in the view dynamically?

i geht in an other controller, for example: 3 pages -> page1, page2, page3.

i have to dynamically create 3 pages in the view, with this data, but the view is called before i have recieved the data. this is my first problem. the second would be how i can i create them dynamically.

br alex

kammaje_cis
Active Contributor
0 Kudos

I hope you are using the callback method for the request to backend.

I would try using rerender() method for the view/page/control in the callback method.

Other approach is to triiger a method to create the controls in callback method.

regards

Krishna

Former Member
0 Kudos

hi,

for sure im using the callback method. BUT:

i have defined a function in the controller, it does some data transformation and the backend-call.

i call the function from the ui, because i need to create dynamically pages, which are defined in the backend.

i want to create the controls dynamically after the call.

br alex