cancel
Showing results for 
Search instead for 
Did you mean: 

Extending the My Travel and Expense app (TRV_TE_CRE) - Hide 'Add Cost Assignment' Button

former_member549737
Participant
0 Kudos

Hello,

We are extending the My Travel and Expense application (TRV_TE_CRE) to:

(1) Hide the “Add Cost Assignment” button, and

(2) Make the whole “Cost Assignment” area display only. (see screenshot - in red)

From what we can tell, the form is located within the S4 View that loads up the Page “S4DetailPage” using S4 Controller.

We are assuming that we have to do a controller extension on S4, but we can’t seem to get a handle on these controls to make them invisible\readonly?






Any help on this would be great.

Thank you,

Rob

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member245094
Discoverer
0 Kudos

Hi Guys,

I got to solve it using a kind of manually fragment extension.

I copied the fragment from the standard project and pasted it to the extension project, renaming it with the "Custom" termination (from "S4.fragment.xml" to "S4Custom.fragment.xml"😞

After that, I changed the reference for this fragment at the S4Custom.controller.js, at point of fragment initialization (method handleRouteMatched, line 182, from "mytravelandexpense.view.S4" to "mytravelandexpense.TRV_TE_CREExtension.view.S4Custom"), like the source code below:

Finally, I commented the "Add Cost Assignment" button source code on S4Custom.fragment.xml:

So it worked and the button is not being shown anymore:

As the SAP Web IDE don't provide the fragment extension wizard (as it is provided for view and controller), I think this way we work with fragment extension.

Regards,

Jairo Canuto

former_member549737
Participant
0 Kudos

Hello,

We have used view modification to make field invisible many times, but this application is built differently. These controls (example id: costAssignmentAddButton) is embedded within a page and a Fragment, so using a simple ‘Hide Control’ extension does not work.

In the S4 extension controller, we can’t seem to get any of these statements below to work. Seems like there is a Page S4DetailPage involved, and we don’t know how to get handle of these controls within the page.

  1. this.getView().byId("costAssignmentAddButton").setVisible(false);
  2. sap.ui.getCore().byId(this.createId("costAssignmentAddButton")).setVisible(false);

Thanks,
Rob,

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rob,

Have you tried this on the S4 Custom Controller:


onAfterRendering : function(){

  var buttonToHide = this.getView().byId("costAssignmentButton");

  buttonToHide.setVisible(false);

},

Regards,

Ivan

gill367
Active Contributor
0 Kudos

Hi

try finding out the IDs of the controls and then use view modification for making fields invisible.

controller extension for read only fields.

Regards,

Sarbjeet Singh