Created
November 28, 2012 21:59
-
-
Save indaco/4164959 to your computer and use it in GitHub Desktop.
SAPUI5 calls CRM Contact REST/OData Service via SAP NetWeaver Gateway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SAPUI5 CONTROLLER | |
sap.ui.controller("sample.ContactList", { | |
// ... | |
onInit: function() { | |
var oModel = new sap.ui.model.odata.ODataModel("http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact", false, 'user', 'pass'); | |
this.getView().setModel(oModel); | |
var oTable = this.byId("contacts_table"); | |
oTable.bindRows("/ContactCollection", null, [new sap.ui.model.Filter("SearchTerm", sap.ui.model.FilterOperator.EQ, "Gateway")]); | |
}, | |
// ... | |
}); | |
// SAPUI5 VIEW | |
var ODataModel = sap.ui.model.odata.ODataModel | |
, MatrixLayout = sap.ui.commons.layout.MatrixLayout | |
, Panel = sap.ui.commons.Panel | |
, Title = sap.ui.commons.Title | |
, TextField = sap.ui.commons.TextField | |
, TextView = sap.ui.commons.TextView | |
, Label = sap.ui.commons.Label | |
, Table = sap.ui.table.Table | |
, Column = sap.ui.table.Column | |
, SelectionMode = sap.ui.table.SelectionMode; | |
sap.ui.jsview("samplee.ContactList", { | |
createContent : function(oController) { | |
// main orders table | |
var oTable = new Table({ | |
id : this.createId("contacts_table") | |
title: "Contact Connection", | |
width: "70%", | |
visibleRowCount: 10, | |
selectionMode: SelectionMode.Single, | |
editable: false | |
}); | |
var aContactColumns= [ | |
{header: "Value", value: "{Value}", sortProperty: "{Value}"}, | |
{header: "First Name", value: "{FirstName}", sortProperty: "{FirstName}"}, | |
{header: "Last Name", value: "{LastName}", sortProperty: "{LastName}"}, | |
]; | |
aContactColumns.forEach(function(column) { | |
var oColumn= new Column({ | |
label: new Label({text: column.header}), | |
template: new TextView({text: column.value}), | |
sortProperty: column.sortProperty | |
}); | |
oTable.addColumn(oColumn); | |
}); | |
return oTable; | |
}, | |
// ... continue ... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment