<!DOCTYPE html>
<html style="height: 100%;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Demo</title>
<script id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-async="true"
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-compatversion="edge"
data-sap-ui-resourceroots='{ "demo": "./" }'
data-sap-ui-xx-componentpreload="off"
></script>
</head>
<body id="content" class="sapUiBody">
<div style="height: 100%;"
data-sap-ui-component
data-id="rootComponentContainer"
data-name="demo"
data-height="100%"
data-settings='{ "id": "rootComponent" }'
></div>
</body>
</html>
{
"_version": "1.33.0",
"start_url": "index.html",
"sap.app": {
"id": "demo",
"type": "application",
"title": "foo",
"applicationVersion": {
"version": "1.0.0"
}
},
"sap.ui": {
"technology": "UI5",
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"dependencies": {
"minUI5Version": "1.40.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.table": {},
"sap.ui.unified": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"jsonModel": {
"type": "sap.ui.model.json.JSONModel",
"uri": "localData/data.json",
"preload": true
}
},
"rootView": {
"id": "rootView",
"viewName": "demo.view.App",
"type": "XML",
"async": true
},
"routing": {
"routes": [{
"pattern": "",
"name": "home",
"target": "home"
}],
"targets": {
"home": {
"viewName": "Home",
"viewLevel": 1
},
"notFound": {
"viewName": "Home",
"transition": "show"
}
},
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "demo.view",
"transition": "slide",
"controlId": "myApp",
"controlAggregation": "pages",
"bypassed": {
"target": "notFound"
}
}
}
}
}
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
>
<App id="myApp">
<pages>
<!-- views will be placed in here by router targets -->
</pages>
</App>
</mvc:View>
<mvc:View
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns:table="sap.ui.table"
controllerName="demo.controller.Home"
>
<Page
title="Products ({= ${thisView>/count}||${jsonModel>/Products}.length})"
backgroundDesign="List"
>
<headerContent>
<SearchField liveChange=".onSearchFieldLiveChange" />
</headerContent>
<table:Table id="myTable" title="sap.ui.table.Table" rows="{
path: 'jsonModel>/Products',
templateShareable: false,
key: 'key',
events: {
change: '.onChange'
}
}">
<table:columns>
<table:Column label="Column1" template="jsonModel>ProductName"/>
</table:columns>
</table:Table>
</Page>
</mvc:View>
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"sap/ui/core/ComponentSupport",//https://github.com/SAP/ui5-tooling/issues/381
], function(UIComponent, Device) {
"use strict";
return UIComponent.extend("demo.Component", {
metadata: {
manifest: "json",
interfaces: [
"sap.ui.core.IAsyncContentCreation", // https://openui5.hana.ondemand.com/api/sap.ui.core.IAsyncContentCreation
],
},
init () {
UIComponent.prototype.init.apply(this, arguments);
this.setDensity().getRouter().initialize();
},
setDensity ({
styleClass = Device.system.desktop ? "sapUiSizeCompact" : "sapUiSizeCozy",
targetElement = document.body,
} = {}) {
targetElement.classList.add(styleClass);
return this;
},
});
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/Filter",
"sap/ui/model/json/JSONModel",
], function(Controller, Filter, JSONModel) {
"use strict";
return Controller.extend("demo.controller.Home", {
onInit: function() {
this.getView().setModel(new JSONModel({ count: 0 }), "thisView");
},
onSearchFieldLiveChange: function(event) {
const query = event.getParameter("newValue").trim();
this.byId("myTable").getBinding("rows").filter(new Filter({
path: 'ProductName',
operator: 'Contains',
value1: query,
}), "Application");
},
onChange: function(event) {
const newCount = event.getSource().getLength();
this.getView().getModel("thisView").setProperty("/count", newCount);
},
});
});
{
"Products": [
{
"key": 1,
"ProductName": "Chai"
},
{
"key": 2,
"ProductName": "Aniseed Syrup"
},
{
"key": 3,
"ProductName": "Konbu"
},
{
"key": 4,
"ProductName": "Rhönbräu Klosterbier"
},
{
"key": 5,
"ProductName": "Fiery Hot Pepper Sauce"
}
]
}