Skip to Content
0
Jan 23, 2013 at 09:05 PM

OData model binding problem

293 Views

Hello experts, I'm experiencing a challenge and I was wondering if any one can help.

I'm tring to bind a field of an OData model to an Input control in a mobile app. The challenge that I have is, the input is always empty. I guess maybe I'm missing something. Below is my code:

// Create the model

var oModel = new sap.ui.model.odata.ODataModel(serviceURL, true);

// Compose path. With the primary key provided, this path will locate a single contact

var path = "/ContactCollection(" + "Value=" + value + "," + "Scheme_ID=" +

schemeID+ "," + "Scheme_Agency_ID=" + schemeAgencyID + ")";

// Create the input control and bind data

var fullNameInput = new sap.m.Input(

{

type: sap.m.InputType.Text,

});

// Set model

fullNameInput.setModel(oModel);

// Bind element

fullNameInput.bindElement(path, {select: "FullName"}); // Get "FullName" field of the contact

I’m sure all the paths are correct. No any error is reported by the browser. The input control is just always empty. I also tried bindValue:

fullNameInput.bindValue(path + "/FullName", null, sap.ui.model.BindingMode.Default);

Also no luck.

Looking forward to getting some support. Thanks.