cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable the save button only when all the fields are filled in SAPUI5.

Former Member
0 Kudos

Hi Experts.

I have requirement to enable the save button when all fields are filled.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

brian_keenan
Contributor

The first part, where you define the model, this should be in the init

when a field is updated you will need to call some function to check them all and then update the model accordingly

Former Member
0 Kudos

Thanks ,

please can you send any sample code.

brian_keenan
Contributor

here you should use the view model,

// View Model 
var oViewModel = new JSONModel({}); 
this.getView().setModel(oViewModel, "viewModel"); 
this.getView().getModel("viewModel").setProperty("/bEdit", false);

when all the fields are complete

this.getView().getModel("viewModel").setProperty("/bEdit", true);

Then in the XML you can bind the edit property of the button to the bEdit parameter of the model

Former Member
0 Kudos

In which part of the controller should we write this code/