Skip to Content

Show/Hide form container using checkbox control UI5

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...

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Dec 13, 2016 at 10:01 AM

    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);
    Add comment
    10|10000 characters needed characters exceeded