cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass values from a client based model from one view to another using eventBus?

former_member356284
Participant
0 Kudos

Hi All,

I am trying to pass a model from one controller to another.

Static data is getting passed using the event bus technique.

But when it comes to passing a model, then I am not able to get back any data.

Please give me the right syntax to pass a model in this context.

I tried almost everything.

This is the first master controller.capture1.png

This is the second detail controller capture2.png

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

usually we don't that, model can be stored at component level, which can be accessed in any view directly.

former_member356284
Participant
0 Kudos

Thanks Jun.

Yeah, that's right.

But could you just suggest me some technique by which I could flow the client based json data from one controller to another.

Thank you for the help. 🙂

Regards,

Aakanksha

Answers (2)

Answers (2)

gowrinath_gundu
Participant
0 Kudos

Hi Akanksha,

set the model to core in view1 and you can acess this in view2.

sap.ui.getCore().setModel()

Alternatively, set it at component level.

Regards,

Gowrinath

former_member356284
Participant
0 Kudos

Thanks Gowrinath.

Actually, I am a beginner in this field of SAPUI5. I am trying to implement a master detail application.

I wanted to select a field from the master view and display its details in the detail view.

I am able to select the data and flow only static data from one master to detail controller.

As a result of which I am updating the view accordingly.

Thanks for the reply 🙂

Regards,

Aakanksha Gupta

former_member183473
Participant
0 Kudos

Hi Aakanksha,

Don't know if its exactly what you are looking for, but this is how i usually pass data from one controller to the other, maybe you can pass an odata object too.

view.byId("idAppControl").to("FullScreen", "fade", {
"pageToGetBack" : "DashBoard",
"itemToShow" : table,
"title" : _title
});

//and on the fullscreen controller i have this code
onInit : function(evt) {

		this.getView().addEventDelegate({
			onBeforeShow : function(evts) {
                                //inside evts.data will be all the parameters you passed
				_that.pageToReturn = evts.data.pageToGetBack;
				page.setTitle(evts.data.title);
				}
		});


Best

Leandro

former_member356284
Participant
0 Kudos

Thanks Leandro.

I used this technique earlier, but there was a route based issue everytime.

So I switched on the eventBus technique.

Here, using this static data was flowing well, but the client based json file was not flowing based on the primary key.

Thanks for the help. 🙂

Regards,

Aakanksha Gupta