Skip to Content
0

Use Function from one controller to the other, possible ?

Aug 28, 2017 at 11:52 AM

48

avatar image

Hello there,

I am currently stuck with something, nobody in the World might have ever had to do.

I have 3 Controllers, and i want the 3rd to use a function from the first.

here is how it looks:

this is my Master controller, it has a function called "onRefresh" which i want triggered.

This is the Detail Controller with a function call to the Dialog.

and this, finally is my ApprovalDialog controller, from which i want the ListRefresher to be executed for the Master View as soon as the confirm Button is triggered. I just don't know how this can be done, or if at all.

Do you know if there is an Answer ?

Thanks warmHeartedly in advance!

3.png (22.1 kB)
2.png (45.3 kB)
1.png (47.5 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Jun Wu Aug 28, 2017 at 12:04 PM
0

use event bus

google it, if don't know

Show 1 Share
10 |10000 characters needed characters left characters exceeded
0
avatar image
Former Member Aug 28, 2017 at 02:48 PM
1

You could use event bus, but if what you want to do is to refresh the master list after success the request then you can do this:

MessageBox.show(
				"Message you want to show", {
					icon: oMessageBox.Icon.SUCCESS,
					onClose: function() {
						oModel.setRefreshAfterChange(true);
						oModel.refresh(true);
						oModel.attachEventOnce("requestCompleted", function() {
							navBack();
						});
					}
				}
			);

With this, you ensure to refresh and only after the request is completed to go back.

Greetings.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Aug 31, 2017 at 07:23 AM
1

Hi Gzim,

Try this -> sap.ui.getCore().byId("myview").getController().myMethod();

Best Regards,

Yoppie A.

Share
10 |10000 characters needed characters left characters exceeded