Skip to content

Instantly share code, notes, and snippets.

View cschuff's full-sized avatar

Christian Schuff cschuff

  • Christian Schuff IT-Consulting
  • Mannheim, Germany
View GitHub Profile
@cschuff
cschuff / AssignmentShortcuts.js
Last active February 24, 2017 16:22
Assignment Shortcuts
// boolean defaulting to true
bValue = (bValue !== false);
bValue = bValue === undefined ? this.getValue() : bValue;
sValue = sValue || "default";
@cschuff
cschuff / MangedObjectConstructor
Last active February 7, 2017 08:47
Aggregation types not inherited from sap.ui.base.ManagedObject
constructor: function (sId, mSettings) {
// https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/base/ManagedObject.js#create
var oMyAggregation;
if ((sId && sId.myAggregation) || (mSettings && mSettings.myAggregation)) {
// delete from settings so that applySettings will not pick it up
if (sId && sId.myAggregation) {
oMyAggregation = sId.myAggregation;
delete sId.myAggregation;
}
if (mSettings && mSettings.myAggregation) {
@cschuff
cschuff / gist:275f4b66c155e71ab31a6df404dcfc7a
Last active February 6, 2017 14:57
ODataModel Obstacles
// always use createKey since for getData/getProperty
// "/EntitySet(Prop1='VAL-1',Prop2='VAL-2')" !== "/EntitySet(Prop2='VAL-2',Prop1='VAL-1')"
// Be aware that createKey needs ODataModel metadata
oModel.metadataLoaded().then(function () {
var sKey = oModel.createKey("/EntitySet", {
Prop1: "VAL-1",
Prop2: "VAL-2"
});
});
@cschuff
cschuff / DataType.js
Last active May 30, 2019 09:05
Valid SAPUI5 property types
// found in https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/base/DataType.js
"any"
"boolean"
"int"
"float"
"string"
"object"
"function"
// arrays like this
@cschuff
cschuff / sap.ui.model.Sorter: Custom Sort Comparator
Last active January 28, 2017 12:36
A custom comparator that converts strings to number and compares them. Demonstrates usage in sap.ui.model.Sorter.
// String to Number Comparator
var oSorter = new sap.ui.model.Sorter("path");
oSorter.fnCompare = function (a, b) {
var valA = parseInt(a, 10);
var valB = parseInt(b, 10);
if (isNaN(valA)) return 1;
if (isNaN(valB)) return -1;
if (isNaN(valA) && isNaN(valB)) return 0;