Skip to Content
0

OData v4 filtering does not work in sapui5

Apr 06 at 08:49 AM

17

avatar image

Hi folks,

I am trying to count the number of rows with specific value in "firstName" column, in OData v4. After googling I found out that I can't use the read function or doing this through ajax in Odata v4, so I decided to bind the items with filtered value to a table and count the number of items in table. To do so, I used the following codes in sapui5. Unfortunately, filtering does not work and I get all the items in my table not just the filtered items. Any Idea?

XML:

<Table id="booksTable" width="auto" inset="false">
<columns>
	<Column>
	  <Text text="order Number"/> 
	</Column>
	<Column demandPopin="true" minScreenWidth="Tablet"> 
	  <Text text="First Name"/> 
	</Column> 
	<Column> 
	  <Text text="Price"/> 
	</Column> 
</columns>
<items> 
  <ColumnListItem id="columnListItem"> 
	<cells> 
	  <ObjectIdentifier title="" text="{ordersModel>orderNo}"/> 
		<Text text="{ordersModel>firstName}"/> 
	<ObjectNumber unit="{ordersModel>orderCurrency}" number="{ parts:[{path:'ordersModel>orderAmount'},{path:'ordersModel>orderCurrency'}], type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }"/> 
        </cells> 
  </ColumnListItem>
</items></Table>

In JS:

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/ui/model/Filter",
	"sap/ui/model/FilterOperator",
	"sap/ui/model/json/JSONModel"
], function(Controller, Filter, FilterOperator, JSONModel) {
	"use strict";


	return Controller.extend("KPI.ui.controller.KPIview", {
		onInit: function() {
                    this._oView = this.getView();
			this._oItemsTable = this.byId("booksTable");
			this._oItemTemplate = this.byId("columnListItem").clone();

	this._oItemsTable.bindItems({
			    path : "ordersModel>/Orders",
			    parameters : {
			        filter : "firstName eq 'Samin'",
			        select : ["orderNo","firstName","orderCurrency","orderAmount"]
			    },
			    template: this._oItemTemplate
			});
}

		
	
	});
});
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers