<!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"
data-sap-ui-xx-waitfortheme="init"
></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.12.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": {}
}
},
"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"
controllerName="demo.controller.Home"
>
<Page
title="Products ({= ${jsonModel>/Products}.length})"
backgroundDesign="List"
>
<List id="list"
mode="Delete"
delete=".delete(${$parameters>/listItem})"
items="{
path: 'jsonModel>/Products',
templateShareable: false,
key: 'key'
}"
>
<StandardListItem title="{jsonModel>ProductName}" />
</List>
</Page>
</mvc:View>
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
], function(UIComponent, Device) {
"use strict";
return UIComponent.extend("demo.Component", {
metadata: {
manifest: "json"
},
init: function() {
UIComponent.prototype.init.apply(this, arguments);
this.setDensity().getRouter().initialize();
},
setDensity: function({
styleClass = Device.support.touch ? "sapUiSizeCozy" : "sapUiSizeCompact",
targetElement = document.body,
} = {}) {
targetElement.classList.add(styleClass);
return this;
},
});
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
], function(Controller) {
"use strict";
return Controller.extend("demo.controller.Home", {
delete: function(listItem) {
const context = listItem.getBindingContext("jsonModel");
const model = context.getModel();
const indexToDelete = +context.getPath().split("/").reverse()[0];
const byIndex = (item, index) => index !== indexToDelete;
const newCollection = model.getProperty("/Products").filter(byIndex);
model.setProperty("/Products", newCollection, null, true);
},
});
});
{
"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"
}
]
}