Skip to content

Instantly share code, notes, and snippets.

@indaco
Created November 28, 2012 21:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save indaco/4164959 to your computer and use it in GitHub Desktop.
Save indaco/4164959 to your computer and use it in GitHub Desktop.
SAPUI5 calls CRM Contact REST/OData Service via SAP NetWeaver Gateway
// 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