Skip to Content
0

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

Mar 06, 2017 at 10:52 AM

114

avatar image
Former Member

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

capture1.png (29.8 kB)
capture2.png (37.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Jun Wu Mar 06, 2017 at 01:31 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
avatar image
Former Member Mar 06, 2017 at 11:19 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
avatar image
Former Member Mar 06, 2017 at 09:40 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0