Skip to Content
0

Show/Hide form container using checkbox control UI5

Dec 12, 2016 at 04:43 PM

41

avatar image

Hi,

I have tried setting the visibility setting on the formContainer control to false, then within the controller.js have a function with an if statement to show/hide the fields. this initially hides and then shows when the checkbox is clicked however does not re-hide them once the checkbox is clicked again.

This should be a simple question..., can the "visible" property of the formContainer within an XML view be bound to a Checkbox control in the same view by use of a model - and if so, please could someone show me the syntax?

Plenty of examples creating the view straight from the controller or on HTML pages but can't seem to get anything to work using controller.js with xml views...

10 |10000 characters needed characters left characters exceeded

Can you please paste your code ? The View and Controller.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Radek Chudziak Dec 13, 2016 at 10:01 AM
0

In onInit method of your view's controller create a JSON model and set it to the view e.g.

onInit: function() {
var oViewModel = new JSONModel({
isVisible: true });
this.setModel(oViewModel, "objectView");
}

Then bind the isVisible property to your form visibility property e.g. {objectView>/isVisible}

Then in the event of the checkbox you can manipulate that property e.g.

this.getModel("objectView").setProperty("/isVisible", false);
Share
10 |10000 characters needed characters left characters exceeded