cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable the create button in the Flexible Programming Model?

jorbriceno
Explorer
450

Hi, everybody.

I have a problem with my custom page. I can currently see what I want but the create button is only visible when I enter edit mode. How do I make the button visible without having to edit some record?

I am using a service made in CAP and I have draft enabled.

Edit mode

jorbriceno_0-1732116604000.png

Reading mode

jorbriceno_1-1732116653867.png

 

 

View Entire Topic
MattDion
Participant
0 Kudos

Found the answer... in one of the controller extension functions (I put it in onInit), you need to add the line:

this.getView().getModel("ui").setProperty("/isEditable", true);

jorbriceno
Explorer
0 Kudos

Hi, MattDion.

As a temporary solution it is correct. But, visually it is not pleasant to have all the items in edit mode.

However, the solution of @mariusfreitag is nice. But it also has certain drawbacks. As commented by @anilnagvanshi on the Youtube channel.

"What i observed in this video, is that even though the developer is using a custom button to create a record in the Table in draft state, the moment he edits the draft record or even if he edits the existing records, there is a separate "Create" button that comes up in the Header of the Table. Now two things related to this behaviour:
1. If the Table rendered by Fiori elements' Line Item annotation in a Custom Page, has a "create" button, why doesn't it show up in the first place, why only in the scenario when the particular record of the entity is in Edit mode.
2. If the developer had to use a custom button to create entity in draft state, he should've disabled the upcoming of "Create" button when the record is in editing mode."

On the other hand, when trying to use the cancel button I got the following error:

jorbriceno_0-1739897521145.png

And it didn't show me the standard message either, so I made an adjustment as shown below:

jorbriceno_1-1739897652537.png

Preview:

jorbriceno_2-1739897693623.png

Is there a way to make the create button appear right away? Without having to enter edit mode? Otherwise, is it possible to edit just one item and not all of them?

 

jorbriceno
Explorer
As a solution for the Main view, what I did was replace the template: sap.fe.core.fpm with sap.fe.templates.ListReport and with this I get the desired behavior and in the rest of the navigations without problems I can use: sap.fe.core.fpm.