cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Value Help data binding

Former Member
0 Kudos

Hi,

could you please help with this issue regards value help dialog? My code looks as follows: (based on the UI5 Explored)

Component.js:

// Create and set domain model to the component
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, {
json: true,
loadMetadataAsync: true
});
this.setModel(oModel);

In the controller:

    oValueHelpDialog.getTable().setModel(sap.ui.getCore().getModel("oModel"));

//var oRowsModel = new sap.ui.model.json.JSONModel();
//oRowsModel.setData(this.aItems);
//oValueHelpDialog.getTable().setModel(oRowsModel);
if (oValueHelpDialog.getTable().bindRows) {
oValueHelpDialog.getTable().bindRows("/SoldToSearchSet"); 
}

I do not get any data visible, what is wrong with my databinding?

Thanks,

Tim

Accepted Solutions (1)

Accepted Solutions (1)

former_member228602
Contributor
0 Kudos

Hello Tim,

You have set the model on the component but while accessing you are the global ui5core model and therefore not visible. In the controller you have reference to the Owner Component.

Another option is to set global model by using sap.ui.getCore().setModel() -- But this is strictly not recommended.

The solution is - In controller file

oValueHelpDialog.getTable().setModel(this.getOwnerComponent().getModel("oModel"));

This way you will be able to have the component's model set to value help table. Hope this helps.

Thanks and Regards,

Veera

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos
sap.ui.getCore().setModel(oModel)