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 / StopItControl.js
Created April 3, 2017 12:32
Stop OData Aggregation Bindings from heavy blinking
invalidate: function () {
var oBinding = this.getBinding("plannings");
// do not rerender during odate request is running since it causes heavy blinking
if (!oBinding || !oBinding.bPendingRequest) {
Control.prototype.invalidate.apply(this, arguments);
}
},
@cschuff
cschuff / npm.sh
Last active March 20, 2017 08:33
npm
# show available versions of an npm package
npm show [PACKAGE_NAME] versions
@cschuff
cschuff / XMLViewWithFragment.view.xml
Created March 14, 2017 10:58
Usage of Fragments in SAPUI5 XMLViews
<core:View xmlns:core="sap.ui.core"
xmlns="sap.m"
controllerName="ui5experts.Root">
<core:Fragment fragmentName="ui5experts.fragment.Fragment" type="XML" />
</core:View>
@cschuff
cschuff / karma.conf.js
Last active March 15, 2017 09:27
A freshly generated karma.conf.js using 'qunit' and PhantomJS'. Generated using '$ karma init karma.conf.js'
// Karma configuration
// Generated on Wed Mar 08 2017 11:21:46 GMT+0100 (CET)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
@cschuff
cschuff / SortComparatorCollection.js
Created February 24, 2017 13:26
Sort Comparators for sap.ui.model.Sorter
// ISO Date as string
function (a, b) {
var valA = a.split("T")[0];
var valB = b.split("T")[0];
if (valA < valB) return -1;
if (valA > valB) return 1;
return 0;
};
// string as number
@cschuff
cschuff / SuspendResumeBindings.js
Last active February 22, 2017 13:13
How to suspend and resume a Binding in SAPUI5 without having resume refresh it if it has pending changes from the suspended period. This can be particularly helpful if your UI already reflects the changes and you want to prevent additional rerenderings (e.g. after drag and drop operations).
var oBinding = this.byId("Control").getBinding("items");
oBinding.suspend();
// ...
oBinding.bPendingRefresh = false;
oBinding.resume();
@cschuff
cschuff / findAggregatedObjects.js
Created February 22, 2017 10:33
Find an aggregated SAPUI5 object
// https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.base.ManagedObject.html#findAggregatedObjects
var aResults = oObject.findAggregatedObjects(true, function(o) { return o.getId() === "TEST"; });
@cschuff
cschuff / JSDocDemo.js
Last active October 9, 2022 13:55
How to document a SAPUI5 class with regular JSDoc
/**
* @namespace
* @name ui5experts.toolbox
* @public
*/
sap.ui.define([
"sap/ui/base/ManagedObject"
], function (
ManagedObject) {
@cschuff
cschuff / RoutePatternMatched-Auto-Attach
Created February 8, 2017 08:36
Auto-attach to patternMatched event on correct sap.ui.core.routing.Route
////////////////////////////////
// Controller Lifecycle
onInit: function () {
this.getRouter().attachRoutePatternMatched(this.onAnyRoutePatternMatched, this);
},
onExit: function () {
this.getRouter().detachRoutePatternMatched(this.onAnyRoutePatternMatched, this);
this.getRouter().getRoute(this.routeName).detachPatternMatched(this.onRoutePatternMatched, this);
var FnConstructor = jQuery.sap.getObject(sType);