Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Hide button on the event.

Hello!

Please help understand the problem.

I created a view.

Inside view is page.

<mvc:View

    controllerName="sap.ui.....forms.controller.FormGoals"

    height="100%"

    xmlns="sap.m"

  xmlns:mvc="sap.ui.core.mvc"

  xmlns:core="sap.ui.core"

  xmlns:l="sap.ui.layout"

  xmlns:f="sap.ui.layout.form">

   

  <Page

  id="formgoals_page"   

     showHeader="true"

  title="First Page"

  enableScrolling="true"

  class="gsjPageStyle">

     <customHeader>

  <Toolbar>

  <ToolbarSpacer/>

  <Title text="{main_data>/output/empl_fio}" />

  <ToolbarSpacer/>

  </Toolbar>

  </customHeader>

    

  <content>  

  <l:VerticalLayout width="100%">

  <!--

  <Label text="{main_data>/output/empl_fio}"/>

  <Label t

  ..........................................

  <footer id="formgoals_footer">

  </footer>

  </Page>

</mvc:View>

Footer page is created in the fragment.

In footer has several buttons. When I click one of them, the others have to hide.

sap.ui.jsfragment("sap.ui.x5.forms.view.FormGoals_Footer_Toolbar", {

  createContent: function(oController) {

  var o_toolbar;

  var button_save;

  var button_cancel;

  var button_comments;

  var o_dfc = oController.getOwnerComponent().main_data; //Sturcture

  var o_settings_data = oController.getOwnerComponent().settings_data; //Sturcture

  button_edit = new sap.m.Button("btnEdit", {

  text: ("Edit"),

  visible: true

  press: [oController.handleEditPres, oController]

  });

  button_cancel = new sap.m.Button("btnCancel", {

  text: ("Cancel"),

  visible: true

  press: [oController.handleCancelPress, oController]

  });

  button_comments = new sap.m.Button("btnComment", {

  text: ("Comment"),

  visible: true,

  press: [oController.handleShowComments, oController]

  });

  o_toolbar = new sap.m.Toolbar({

  content: [button_comments,

           new sap.m.ToolbarSpacer(),

           button_save,

           button_cancel]

  });

  return o_toolbar;

  }

});

To implement this function, I get the view from the controller.

sap.ui.define([

  'jquery.sap.global',

  'sap/m/Dialog',

  'sap/m/MessageToast',

  'sap/ui/core/Fragment',

  'sap/ui/core/mvc/Controller',

  'sap/ui/model/json/JSONModel',

  ], function(jQuery, Dialog, MessageToast, Fragment, Controller, JSONModel) {

  "use strict";

  var sResult = '';

  var FormGoalsController = Controller.extend("sap.ui......forms.controller.FormGoals", {

  onInit: function (oEvent) {

  var main_page;

  main_page = this.getView().byId('formgoals_page');

  main_page.setFooter(this._getFormFragment("FormGoals_Footer_Toolbar"));

  },

  //....

  _formFragments: {},

  _getFormFragment : function (sFragmentName) {

  var oFormFragment = this._formFragments[sFragmentName];

  if (oFormFragment) {

  return oFormFragment;

  }

  oFormFragment = sap.ui.jsfragment("sap.ui......forms.view." + sFragmentName, this);

  return this._formFragments[sFragmentName] = oFormFragment;

  },

  //....

  handleEditPress: function(){

  var o_view = this.getView();

  o_view.byId("btnComment").setVisible(false); //ERROR!!!

  o_view.byId("btnCancel").setVisible(false);

  var o_view_mono_table = o_view.byId("mono_table_main");

  o_view_mono_table.getController()._showFormFragment("MonoTable_Edit");

  o_settings_mod.setProperty("/edit_tables", !edit_stat);

  o_settings_mod.refresh(true);

  },

  //....

  return FormGoalsController;

});

And I try to get the ID of the button to hide them. But I get this error:

Uncaught TypeError: Cannot read property 'setVisible' of undefined

Explain please, what am I doing wrong?

Tags:
Former Member
replied

Hi Sergey,

sap.ui.getCore().byId("btnComment").setVisible(false);

Thanks,

Karthik A

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question