Skip to Content

Use Function from one controller to the other, possible ?

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Aug 28, 2017 at 12:04 PM

    use event bus

    google it, if don't know

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 28, 2017 at 02:48 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 31, 2017 at 07:23 AM

    Hi Gzim,

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

    Best Regards,

    Yoppie A.

    Add comment
    10|10000 characters needed characters exceeded