Page Is Blank Without Throwing Any Errors

Cause The root view is missing a root control or the height of the parent HTML elements is not set to 100%. The child elements cannot be rendered in full size. Resolution For Standalone or Top-Level Applications Add sap.m.App (or sap.m.SplitApp in case of a master-detail layout) once in the entire application project to your … Read more

How to disable or enable letterboxing and adjust UI5 for the widescreen?

Ok, so there seems to be many similar questions regarding how to disable/enable letterboxing. This answer should provide a solution for each case: Standalone Apps Look for the instantiation of sap.m.Shell in your project and configure appWidthLimited accordingly. For example: In index.html or index.js sap.ui.require([ “sap/m/Shell”, “sap/ui/core/ComponentContainer”, ], (Shell, ComponentContainer) => new Shell({ appWidthLimited: false|true, … Read more

“onBeforeRendering” or “onAfterRendering” is not called every time the view is opened

Why (…) is the onBeforeRendering not triggered every time the view is displayed? I think there is a misconception of what “rendering” means. In UI5, when a control is “rendering”, its corresponding HTML element is being modified or created in the DOM by the RenderManager. I.e. onBeforeRendering means literally “before the render function of the … Read more

Live Update the Number of Items

Client-side Models If a client-side model such as JSONModel is used (i.e. assuming all the data are already available on the client) and if the target collection is an array, a simple expression binding is sufficient: title=”{= ${myJSONModel>/myProducts}.length}” Sample 1 (ClientModel): Updating count after deleting items from sap.m.Table Sample 2 (ClientModel): Updating count after filtering … Read more

How to Set Initial Focus in a View?

Here is a working example: https://embed.plnkr.co/wp6yes/ <App autoFocus=”false” xmlns=”sap.m”> <!– AND/OR –> <f:FlexibleColumnLayout autoFocus=”false” xmlns:f=”sap.f” /> <!– autoFocus in FCL available since 1.76 –> { // Controller of the target view: onInit: function() { this.attachAfterShow(this.onAfterShow); }, attachAfterShow: function(onAfterShow) { this._afterShowDelegate = { onAfterShow }; this.getView().addEventDelegate(this._afterShowDelegate, this); }, onAfterShow: function() { this.byId(“thatControl”).focus(); }, onExit: function() { … Read more

Filter with “OR” And “AND” Conditions on Multiple Fields

Here is a minimal example of combining multiple filters using OData from Northwind: https://embed.plnkr.co/AoIZI4/. The complete list can be found here. When instantiating a filter, instead of path, operator, and value1, use the properties filters and and to combine multiple filters as shown in the Filter API reference. In our case, we define three filters: … Read more

Add a New Item to a Table / List

Resolution Bind the collection of data to the aggregation of table (e.g. <items>). Add a new entry via the model (instead of to the UI directly) when the user clicks on Add. Thanks to the aggregation binding, UI5 will create a new sap.m.ColumnListItem for you and you did not break the MVC pattern. Here are … Read more

Global Model Not Accesible

Avoid setting models on the Core directly if you’re using Components. Components are meant to be independent and reusable parts and therefore will not inherit the Core models by default. Models should be set depending on your business case: Models declared in the app descriptor (manifest.json) section /sap.ui5/models will be set on the Component. They … Read more

How to Access Elements from XML Fragment by ID

Accessing controls inside a fragment depends on how your fragment was created in the first place. Here is a list of cases with respective API to use to get the control reference. Given: this as a reference to the current controller instance Fragment required from the module sap/ui/core/Fragment <MyControl id=”controlId”/> in the fragment definition API … Read more