on 2015 Nov 17 8:51 AM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am working on the client side, I got the server side response as a client side model and set it to the form. And if I use the approach described in the Simple OData Binding with SAPUI5 | SCN answer then I can't read the model efficiently afterwards.
The data that comes from the server is read and set with no problem. It was what happenes moment after that. Plz read my question again.
Will this help? JS Bin - Collaborative JavaScript Debugging
if Not, please share myForm.getModel("ContractElementsData") model data.
Regards,
KA
If i to call myForm.getModel("ContractElementsData").getProperty("/ContrtypeName") then I get undefined.
Yeah I skipped the Model Object properties and just posted the oData part of the Model Object. Perhaps there is a timing problem between when the ContrtypeName is set and when I'm trying to access it? Which still doesn't explain why the same approach works in a different place...
User | Count |
---|---|
31 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.