Skip to Content
avatar image
Former Member

View should call another view's function to create an if-else statement but doesnt work..

Hello,

As I 'm developing my app, I have a page which is included 3 buttons. I created a view has included 1 table which is following on second button but right now, I need when I press the third button view should come but one of the view's table's column shouldn't appear which should come unvisible.

In my opinion, Exactly I should create if-else statement on this view. But how can I create an if else statement referred another view's buttons. ?

button:function(){ 
      
  app.to("page5");     
      
  } 

This is a part of button's view.controller.

Can you help me how can I call from another view this function and do if else statement for I need ?

Thanks,

Ogulcan G.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 16, 2015 at 01:09 PM

    Hi Ogulcan,

    You wanted to call another view's function? If you have the button view id available with you, then try

    var oView = sap.ui.getCore().byId("oButtonView");          //Your View ID where the button is placed.
    oView.buttonFunction();               //Your Button function
    
    

    Regards,

    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Sai Vellanki

      Hi Sai,

      Thank you for your supporting. That was really great changes. As you said thats really big application and this is my first experience with SAPUI5 thats why have so many problems. I hope it will finish as soon 😊

      So, right now I did some changes (connect with ABAP rep.) and again page's title didn't appear too. My changes on the mdetiketbasma.view and mddepgeliade.view also.

      And when I open my Combobox code my table which has values from SAP are gone. Thats why I cant use my combobox too (Logon.view)

      http://plnkr.co/edit/USFhNQ16NBk696Dji4ca?p=info

      These are my last problems. You 're really great supporter and if you support one more time I will really appricate for it.

      THANK YOU FRIEND SAI,

      Ogulcan G.

  • avatar image
    Former Member
    Oct 23, 2015 at 01:51 PM

    If you still want to use an if else you could try one of the following options:

    Option 1: Use browser storage. Of button is pressed then store value. In the other view's controller you just get the item again with the specified key.

         jQuery.sap.require("jquery.sap.storage");

         //set data

         this.storage.put("key", "show"));

         //get data

         this.storage = window.localStorage ? jQuery.sap.storage(jQuery.sap.storage.Type.local) : jQuery.sap.storage(jQuery.sap.storage.Type.session);

         var data = this.storage.get("key");

    Option 2: Using events. Go ahead and have a look at eventBusses (sap.ui.core.EventBus) for communication between views.

    Add comment
    10|10000 characters needed characters exceeded