<mvc:View
controllerName="sap.m.sample.ListCounter.List"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<List
headerText="Fruits"
items="{path:'products>/Products', sorter:{path:'Name'}, filter:{path:'Type', operator:'EQ',value1:'Fruit'}}">
<!-- Template of the list item -->
<StandardListItem
title="{Name}"
/>
</List>
<List
headerText="Food"
items="{path:'products>/Products', sorter:{path:'Name'}, filter:{path:'Type', operator:'EQ',value1:'Food'}}">
<!-- Template of the list item -->
<StandardListItem
title="{Name}"
/>
</List>
</mvc:View>
Controller:
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel'
], function(jQuery, Controller, JSONModel) {
"use strict";
var ListController = Controller.extend("sap.m.sample.ListCounter.List", {
onInit : function (evt) {
// Model
var oModel = new JSONModel("/products.json"));
this.getView().setModel(oModel,"products");
}
});
return ListController;
});
products.json:
{
Products : [
{"Name": "Banana", "Type": "Fruit"},
{"Name": "Meat", "Type":"Food"},
{"Name": "Apple", "Type": "Fruit"},
{"Name": "Rice", "Type": "Food"},
]
}