on 10-15-2015 7:03 PM
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?
Hi Sergey,
sap.ui.getCore().byId("btnComment").setVisible(false);
Thanks,
Karthik A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alternively you can bind the visibility property of the buttons to a property in a model. If you want to change the visibility, just change the value in the model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
o_view.byId("btnComment").setVisible(false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use
o_view.byId("btnComment").style.visibility = 'hidden';
and
o_view.byId("btnComment").style.visibility = '
visible
';
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
when you create a fragment, first param is frgament id
oFormFragment = sap.ui.jsfragment("FRAGMENT_ID", forms.view." + sFragmentName, this);
to get controle out of that fragment you call
sap.ui.getCore().byId( "FRAGMENT_ID--btnComment")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.