Skip to Content

How to bind the Visible property to JSON property for existing element


I am customizing standard fiori application with Web IDE and in this application I have below requirement.

I want to add one check box and on selection of the checkbox, one of the existing input field should be shown or hidden.

Same field is there on the multiple screens. So, I have to add check box on the multiple screens. But, when it is selected on one screen, it should be reflected on another as well.

This is what I have done.

In the init method, I have written below javascript code to add the checkbox.



var that = this;

this.oOtherDate = new sap.m.CheckBox("cOtherDelDate", {

text: "{i18n>OTHER_DELIVERY}",

selected: "{path : 'soc_cart>/showRddInput'}", // This carries the checkbox selection to other pages. It is JSON model.

select: function(oEvent) {

var checked = oEvent.getParameters().selected;

oModelList.getData().showRddList = !checked;

oModelList.getData().showRddInput = checked;




On above code, on the selection event of check box, I am setting the two JSON properties. One for the checkbox value and another to make one element hidden and vice versa.

Upto this point, everything works fine.

BUT, now, how can I bind the JSON property value "showRddList" to the element's visible property?

I have tried doing below but it is giving error:

this.byId("Field1").setVisible("{path : 'soc_cart>/showRddList'}");

setVisible() method expects boolean value and in above line of code, it considers as the string value.

FYI... Element which needs to be hidden is defined on the XML view and we can't extend or customize the view to specify the binding property in the view. So, I have to set it from the controller only.

Is there a possibility to set the visible property from controller to the existing element?


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Apr 15, 2016 at 04:34 AM

    Hi Devisha,

    It should be:

    var oField = this.byId("Field1")


    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 15, 2016 at 05:40 AM

    Hey Devisha,

    Convert the string into boolean using formatter. There are two ways either create a new formatter file and do all the formatting there or format in-line choose according to your requirement.

    Creating Formatter file:

    Please check the below example might this help you :

    In my view i have a button which i have to visible on the basis of the value i get from the backend,

    MAIN VIEW Snippet :

    <Button icon="sap-icon://sys-cancel" id="Rej" press="OnReject" text="Reject" type="Reject" visible="{ path: 'Status', formatter: 'InboxAp.util.Formatter.buttonAR' }"/>

    The value of Status is formatted before its assigned to visible property of button.

    'InboxAp.util.Formatter.buttonAR' path of the buttonAR function which do the conversion from string to boolean.

    Formatter.js file snippet

    buttonAR: function(value){

    //value is the status in your case its showRddList

    if(value == '<yourstring>')

    {return true;}


    return false


    As your using Formatter.js file so please include it in your view before using the above code."<yourProjectName>.<foldername>.Formatter");// path of the Formatter.js file

    In-Line Formatting:

    this.byId("Field1").setVisible("{path : 'soc_cart>/showRddList',

    formatter: function(fValue) {

    if (fValue=="true") {

    return true;



    {return false;}


    Hope this helps you. let me know if you face any challenges.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.