Created
July 17, 2015 14:04
-
-
Save ikiw/bb2de7cd162bd88adf88 to your computer and use it in GitHub Desktop.
Grouping with custom group function UI5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html><head> | |
<meta http-equiv='X-UA-Compatible' content='IE=edge' /> | |
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/> | |
<title>Mobile App with XML View with JSON Data</title> | |
<script id='sap-ui-bootstrap' type='text/javascript' | |
src='/sapui5/resources/sap-ui-core.js' | |
data-sap-ui-theme='sap_bluecrystal' | |
data-sap-ui-libs='sap.m' | |
data-sap-ui-xx-bindingSyntax='complex'></script> | |
<script id="myXml" type="text/xmldata"> | |
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="myController" displayBlock="true"> | |
<App> | |
<Page title="Hello"> | |
<Table | |
items="{ | |
path: '/Customers', | |
sorter: { | |
path: 'Region', | |
descending: false, | |
group: '.getGroup' | |
}, | |
groupHeaderFactory: '.getGroupHeader' | |
}" | |
headerText="Products" > | |
<StandardListItem | |
title="{Name}" | |
description="{ProductId}"/> | |
<columns> | |
<Column> | |
<Label text="Name" /> | |
</Column> | |
<Column> | |
<Label text="ProductId" /> | |
</Column> | |
</columns> | |
<items> | |
<ColumnListItem > | |
<cells> | |
<Text text="{CompanyName}" /> | |
<Text text="{City}" /> | |
</cells> | |
</ColumnListItem> | |
</items> | |
</Table> | |
</Page> | |
</App> | |
</mvc:View> | |
</script> | |
<script> | |
sap.ui.controller("myController", { | |
onInit: function() { | |
var sUrl = "/databinding/proxy/http/services.odata.org/V2/Northwind/Northwind.svc/"; | |
var model = new sap.ui.model.odata.ODataModel(sUrl, {metadataUrlParams: {}, json: true, loadMetadataAsync: true}); | |
this.getView().setModel(model); | |
}, | |
getGroup: function (oContext){ | |
var sKey = oContext.getProperty("Region"); | |
return { | |
key: sKey, | |
title: sKey || "No Specific Region" | |
}; | |
}, | |
getGroupHeader: function (oGroup){ | |
return new sap.m.GroupHeaderListItem({ | |
title: oGroup.title, | |
upperCase: false | |
}); | |
} | |
}); | |
sap.ui.view({ viewContent: jQuery('#myXml').html(), type:sap.ui.core.mvc.ViewType.XML }).placeAt("content") | |
</script> | |
</head> | |
<body class='sapUiBody'> | |
<div id='content'></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider using 'text' property instead of 'title'. In 1.93 'title' is not working.
Fix: