Reputation: 8488
I want to hide a button/area/region(header,footer,etc) when a button is clicked. How can I achieve this? For example if I have the following page:
<mvc:View
height="100%"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Page
title="Hide Area On Button Click" >
<content>
<Button id="btn1" text="Accept" type="Accept" press="onPress" />
<Button id="btn2" text="Reject" type="Reject" />
</content>
<footer>
</footer>
</Page>
</mvc:View>
Now what should be the
onPress : function {//code}
to hide the reject button?
Upvotes: 3
Views: 26772
Reputation: 5713
This code should accomplish that:
onPress:function(oEvent) {
var rejectBtn = this.getView().byId("btn2");
if(rejectBtn.getVisible()) {
rejectBtn.setVisible(false);
}
}
Upvotes: 6