on 03-16-2017 8:51 AM
Hi all,
I have a MasterPage List and need to perform search in that list. I use XML coding for my view. I tried some code for my search field. But it throws me some error and my list is getting hidden after I perform search.
Here's the code what I have tried:
XML view:
<subHeader>
<Toolbar>
<SearchField id="idSearchSo" search="handleSOSearch"></SearchField>
</Toolbar>
</subHeader>
<content>
<List id="idMyRequestList" items="{/GS_Inbox_Pending_ListSet}">
<items>
<ObjectListItem type="Navigation" title ="{EmployeeName}"
number="{AgeingDays}"
numberUnit="{path: 'CreatedDate',type: 'sap.ui.model.type.Date',formatOptions: {style: 'medium'}}"
press="handleSOSelect">
<attributes>
<ObjectAttribute text="{EmployeeId}"></ObjectAttribute>
</ObjectListItem>
</items>
</List>
Controller.js:
handleSOSearch: function(oEvent){
var aFilters = [];
var sQuery = oEvent.getParameter("query");
var oFilter = new sap.ui.model.Filter("EmployeeName","Contains",sQuery);
aFilters.push(oFilter);
var oList = this.getView().byId("idMyRequestList");
var oBinding = oList.getBinding("items");
oBinding.filter(aFilters);
},
Where am I going wrong? can someone help me with this?
Hi.
In your Odata while creating Entity Type mark property- 'EmployeeName' as Filterable.
Please refer attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
view.xml.
........
..........
<ToolbarSpacer/>
<SearchField id="filterQuery" width="50%" placeholder = "Enter a Product ID" search="onFilterProducts"/>
.......
-----------------------------------------------------------------------------------------
controller.js
sap.ui.define([ "sap/ui/core/mvc/Controller",
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"myapp/model/formatter",
"sap/m/GroupHeaderListItem" ], function (Controller, Filter, FilterOperator, formatter, GroupHeaderListItem) {
"use strict"; return Controller.extend("myapp.controller.App", {
formatter: formatter,
......
.........
,
onFilterProducts : function (oEvent) {
// build filter array
var aFilter = [],
sQuery = oEvent.getParameter("query"),
// retrieve list control
oList = this.getView().byId("productsList"),
// get binding for aggregation 'items'
oBinding = oList.getBinding("items");
if (sQuery) { aFilter.push(new Filter("ProductID", FilterOperator.Contains, sQuery)); }
// apply filter; An empty filter array simply removes the filter
// which will make all entries visible again
oBinding.filter(aFilter);
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you check in the backend SAP tcode "/n/iwfnd/error_log"? it might be an issue from the backend, if it is not recorded there just check "st22" for any dumps.
Best Regards,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Once try by adding FilterOperator in the Fitlter object like below
var filter = new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.Contains, query);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Please try to go through the below link:
https://sapui5.hana.ondemand.com/explored.html#/entity/sap.m.SearchField/samples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will this helpful to you? https://plnkr.co/edit/VDS1xX?p=preview
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.