on 2020 Dec 12 12:55 PM
Hello everyone.
I tried to apply filter to a table in SAP UI5 coding.
But it doesn't work.
List.view.xml
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:core="sap.ui.core"
controllerName="sap.cp.webapp.controller.List"
displayBlock="true">
<Page
id="listPage"
title="Sales Order List">
<content>
<Toolbar>
<Title width="100%" text="Filter"/>
<SearchField search=".onCompanyName"/>
</Toolbar>
<Table
id="table0"
items="{path:'/SalesOrderSet',sorter:[{path:'SalesOrderID',descending:false}]}"
>
<columns>
Omission
</columns>
<items>
<ColumnListItem
type="Active"
id="item0"
press="handleListItemPress">
<cells>
<Text
text="{SalesOrderID}"/>
<ObjectIdentifier
title="{CustomerName}"
text="{CustomerID}"/>
Omission
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
</mvc:View>
List.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller",
'sap/ui/model/Filter',
"sap/ui/model/FilterOperator"
],
function (Controller, Filter, FilterOperator) {
"use strict";
return Controller.extend("sap.cp.webapp.controller.List", {
onCompanyName : function (oEvent) {
var oTable = this.byId("table0");
var sQuery = oEvent.getParameter("query");
var oFilter;
oFilter = new sap.ui.model.Filter("CompanyName", "EQ", sQuery);
oTable.getBinding("rows").filter([oFilter]);
}
});
});
On debugging screen, following error is shown.
`Uncaught TypeError: Cannot read property 'filter' of undefined`
Could you possible tell me how to solve this problem, please?
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Its getBinding("items"), not rows, as items is for m.table and rows is for ui.table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear maheshkumar.palavalli
Thank you for your kindness.
I fixed the code and actually the error seems to occur no longer.
However the filtered table doesn't appear on view.
No record is displayed.
Could you tell me how to apply the filtered table on the View, please?
Here is my source.
https://github.com/Auggie9010/fiori_salesorder_list2
Sincerely
Koichiro
Dear jun.wu5
Dear maheshkumar.palavalli
After I change it from "CompanyName" to "CustomerName", it works.
I appreciate you and please forgive this easy mistake.
Let me close this question.
Sincerely
Koichiro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
your column name is CustomerName, not CompanyName, which is used in your filter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
12 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.