Skip to Content
author's profile photo Former Member
Former Member

DataModel Binding Anomaly

Hi, I have a dropdownbox:

new sap.ui.commons.DropdownBox("employeeContractType-dropdownBox", {
  visible: "{oUIProperties>/contract/visible/contractType}",
  enabled: "{oUIProperties>/contract/enabled/contractType}",
  required: "{oUIProperties>/contract/required/contractType}",
  displaySecondaryValues: true,
  selectedKey: "{ContractElementsData>/Contrtype}",
  value: "{ContractElementsData>/ContrtypeName}",
  searchHelpEnabled: true,
  searchHelp: function(oEvent) {
  sap.ui.getCore().byId("employeeContractType-dropdownBox-searchHelp").open();
  },
  layoutData: new sap.ui.layout.GridData({
  span: "L4 M4 S6",
  linebreak: false
  }),
  change: function() {
  }
});

After I create the dropdownbox I call oData webservice and set the model to my form

var oContractElementsModel = new sap.ui.model.json.JSONModel();
  oContractChangeModel.read("/ContractDetailsHRSet('" + employeeCode + "')", {
  async: false,
  success: function(oData) {
  oContractElementsModel.setData(oData);
  myForm.setModel(oContractElementsModel, "ContractElementsData");
  },
  error: function(oError) {
  console.log("Error reading ContractDetailsHRSet: ");
  console.log(oError);
  }
});

Now after i set the model i want to read the VALUE of my Dropdownbox by reading the datamodel property ContrtypeName. But for some reason it returns undefined although when I console the whole model using myForm.getModel("ContractElementsData") right before I read the property then I see that the property does have a value.

Can anyone help me out I am kind of loosing my mind because yesterday I did exactly the same thing on a different WS EntitySet and form elements and it worked fined, but now for some reason it is not working...


Can asdkjadlasdoljasContrtypeName

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Nov 17, 2015 at 09:24 AM

    JSON Model - It is Client Side Model

    ODATA Model - Server Side Model

    Try ODATA Model instead of JSON Model.

    JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel

    For Ex:

    Simple OData Binding with SAPUI5 | SCN

    Regards,

    KA

    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.