cancel
Showing results for 
Search instead for 
Did you mean: 

How to bindProperty to a checkbox

0 Kudos
432

I am executing the following code:

new sap.ui.commons.form.FormElement({

                      label: new sap.ui.commons.Label({

                          text: oBundle.getText(

                              "UI_SERVICE_MODEL_ID"),

                          layoutData: new sap.ui.commons.form.GridElementData({

                              hCells: "5"

                          })

                      }),

                      fields: [new sap.ui.commons.CheckBox().bindProperty("checked", "/validation"),]

                  }),

but the property binding is not working. It is unchecked always.

View Entire Topic
saivellanki
Active Contributor
0 Kudos

Hi Archana,

Are you doing aggregation binding for form?

If so try like this -


fields: [new sap.ui.commons.CheckBox().bindProperty("checked", "validation")

Regards,

Sai Vellanki.

0 Kudos

Hi Sai,

I am not doing aggregation binding.


I have tried

fields: [new sap.ui.commons.CheckBox().bindProperty("checked", "validation")


This is not working as well.

Thanks,

Archana

saivellanki
Active Contributor
0 Kudos

Archana,


Did you try like this as well?

fields: [new sap.ui.commons.CheckBox({checked:"{/validation}"})]


if the above also is not working, Can you share your model response that is bound to this checkbox.


Regards,

Sai Vellanki.

0 Kudos

Hi Sai,

Yes this also I have tried this as well. Not working.

This is my model:

{"d":{"__metadata":{"id":"https://localhost:8083/gateway/odata/RESERVEDFORSAPIGW/REPOSITORYSERVICE/RegisteredServices(guid'f51...')","serviceName":"CRM_OPPORTUNITY","nameSpace":"SAP","serviceVersion":1,"serviceDescription":"CRM Opportunity","status":true,"validation":true,"createdBy":null,"changedBy":null,"createdOn":"\/Date(1445443284466+0330)\/","changedOn":"\/Date(1446206712788+0330)\/","type":"BEP","dpc":"com.sap.gateway.core.bep.dp.ODataProcessor","mpc":"com.sap.gateway.core.bep.md.BEPEdmProvider","modelID":"CRM_OPPORTUNITY_0001","sourceServiceId":null,"technicalServiceName":null,"metaDataUrl":null,"serviceUrl":"https://localhost:8083/gateway/odata/SAP/CRM_OPPORTUNITY;v=1","defaultDestination":"QHD","isDestAssignedForEntity":false,"AssignedDestinations":{"__deferred":{"uri":"https://localhost:8083/gateway/odata/RESERVEDFORSAPIGW/REPOSITORYSERVICE/RegisteredServices(guid'f51..."}},"AssignedDestinationsForEntity":{"__deferred":{"uri":"https://localhost:8083/gateway/odata/RESERVEDFORSAPIGW/REPOSITORYSERVICE/RegisteredServices(guid'f51..."}}}}

Thanks,

Archana

saivellanki
Active Contributor
0 Kudos

Archana,


In console, can you do like this and check whether are you able to get the property value / not?

sap.ui.getCore().getModel("if you have model name").getProperty("/validation");


Regards,

Sai Vellanki.

karthikarjun
Active Contributor
0 Kudos

will this Helpful? JS Bin - Collaborative JavaScript Debugging

Manipulate your JSON model.

Or

Give a rite path to your Element( "/d/Metadata......"

var model = {"d":{"__metadata":

{"id":"https://localhost:8083/gateway/odata/RESERVEDFORSAPIGW/REPOSITORYSERVICE/RegisteredServices(guid'f51...')",

"serviceName":"CRM_OPPORTUNITY","nameSpace":"SAP","serviceVersion":1,"serviceDescription":"CRM Opportunity",

"status":true,"validation":true,"createdBy":null,"changedBy":null,"createdOn":"\/Date(1445443284466+0330)\/","changedOn":"\/Date(1446206712788+0330)\/",

"type":"BEP","dpc":"com.sap.gateway.core.bep.dp.ODataProcessor","mpc":"com.sap.gateway.core.bep.md.BEPEdmProvider","modelID":"CRM_OPPORTUNITY_0001","sourceServiceId":null,

"technicalServiceName":null,"metaDataUrl":null,"serviceUrl":"https://localhost:8083/gateway/odata/SAP/CRM_OPPORTUNITY;v=1","defaultDestination":"QHD",

"isDestAssignedForEntity":false,"AssignedDestinations":

{"__deferred":{"uri":"https://localhost:8083/gateway/odata/RESERVEDFORSAPIGW/REPOSITORYSERVICE/RegisteredServices(guid'f51..."}},

"AssignedDestinationsForEntity":{"__deferred":{"uri":"https://localhost:8083/gateway/odata/RESERVEDFORSAPIGW/REPOSITORYSERVICE/RegisteredServices(guid'f51..."

}}}}};

model = model.d.__metadata;

debugger;

var model1 = new sap.ui.model.json.JSONModel(model);

sap.ui.getCore().setModel(model1);

Thanks,

KA

0 Kudos

Hi Sai,

That was the problem. Somehow the values were not set in the model and hence it was not binding.

It is working fine now.

Thanks,

Archana