I am quite new to SAPUI5. I am enhancing our FIORI applications. I'm not having problems binding the data.
Below is the result of console.log of our odata model
{"d":{"__metadata":{"id":"xxxxx/sap/opu/odata/sap/zlord_my_quotation_srv/QuotationSet('20000036')","uri":"xxxxx/sap/opu/odata/sap/zlord_my_quotation_srv/QuotationSet('20000036')","type":"zlord_my_quotation_srv.Quotation"},"Search":{"__metadata":{"type":"zlord_my_quotation_srv.Search"},"SearchTerm":""},"IcompletionStatus":"C","IcompletionStatusDesc":"Complete","NetValue":"0.00","Currency":"NOK","ValidTo":"/Date(1436486400000)/","ValidFrom":"/Date(1436486400000)/","Division":"10","DistributionChannel":"10","SalesOrganization":"1300","SoldToParty":"EKS","QuotationID":"20000036","RejectionStatus":"","ProcessingStatus":"","SoldToPartyDescription":"EKS / Royal 3310 / N-1234 Norway","CreatedOn":"/Date(1436486400000)/","SalesDocumentTypeDesc":"Quotation","RejectionStatusDesc":"not available","ProcessingStatusDesc":"New","ReferenceStatus":"","ReferenceStatusDesc":"not available","ItemIcompletionStatus":"","ItemIcompletionStatusDesc":"not available","PurchaseOrder":"","SalesDocumentTypeCode":"QT","SalesOrder":"1046","QuotationHeaderSet":{"__deferred":{"uri":"xxxxxx/sap/zlord_my_quotation_srv/QuotationSet('20000036')/QuotationHeaderSet"}}}}
Basically I just want to bind SalesOrder to my UI.
Here is our view.xml
<Label
id="salesOrderLabel"
text="{i18n>Sales Order}"
visible="false"/>
<Text
id="salesOrderText"
value="{path:'SalesOrder'}"
visible="false" />
<Label
id="triggerSalesOrderLabel"
text="Trigger Sales Order"
visible="false"/>
<Button
id="triggerSalesOrderButton"
text="Create Sales Order"
icon="sap-icon://sales-order"
width ="200px"
visible="false" />
And here is our controller
manageSalesOrderFields: function() {
var salesOrderId = "";
//hide all fields
view.byId("salesOrderLabel").setVisible(false);
view.byId("salesOrderText").setVisible(false);
view.byId("triggerSalesOrderLabel").setVisible(false);
view.byId("triggerSalesOrderButton").setVisible(false);
//$.getJSON("/sap/opu/odata/sap/zlord_my_quotation_srv/QuotationHeaderSet('" + quotationId + "')",
$.getJSON("/sap/opu/odata/sap/zlord_my_quotation_srv/QuotationSet('" + quotationId + "')",
function(data) {
//salesOrderId = data.d.SalesOrder;
salesOrderId = data.d.SalesOrder;
//console.log(data);
alert("SO - " + salesOrderId);
if (salesOrderId !== "" ){
view.byId("salesOrderLabel").setVisible(true);
view.byId("salesOrderText").setVisible(true);
}else{
view.byId("triggerSalesOrderLabel").setVisible(true);
view.byId("triggerSalesOrderButton").setVisible(true);
view.byId("triggerSalesOrderButton").detachPress(sap.ui.controller("cus.sd.myquotations.SD_MYQUOTESExtension_Michael2.view.S3Custom").createSalesOrder);
view.byId("triggerSalesOrderButton").attachPress(sap.ui.controller("cus.sd.myquotations.SD_MYQUOTESExtension_Michael2.view.S3Custom").createSalesOrder);
}
var oModel1 = new sap.ui.model.json.JSONModel();
// set the data for the model
oModel1.setData(data);
// set the model to the core
//sap.ui.getCore().setModel(oModel1);
console.log(oModel1.getJSON());
var oSalesOrderText = view.byId("salesOrderText");
oSalesOrderText.setModel(oModel1);
oSalesOrderText.bindElement("value", "SalesOrder");
});
// create JSON model instance
},
There is not error but I cannot get SalesOrder to show in my UI. Can someone point me to the right direction.