on 04-22-2015 10:38 AM
Hi All,
I have a search field in that field i have to enter id means it should search that particular id and if i give name means it should show that particular person name only. please assist me.
Hi,
You have to create the filter like new sap.ui.model.Filter({ filters: [...], and: true|false }), as mentioned in SAPUI5 SDK - Demo Kit
var searchValue = oEvent.getParameter("query");
var filters = [ new sap.ui.model.Filter("Id", sap.ui.model.FilterOperator.Contains, searchValue),
new sap.ui.model.Filter("Name", sap.ui.model.FilterOperator.Contains, searchValue) ];
oFilter = new sap.ui.model.Filter( filters, false ); //False means it will apply an OR logic, if you want AND pass true
//Get binding of component and apply it, let's suppose it's a List
this.getView().byId("list").getBinding("items").filter(oFilter); //
Regards,
Sandro Ramos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you mean you have two search feilds where in one you enter id and in another you enter Name at the same time..? and it should filter based on those two right..?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Refer this thread, it will resolve your issue,
SAPUI5: How to filter data with 2 or more values - Stack Overflow
Hi,
it may help you,
var dropdownval=oDropdown.getValue();
var oFilters = [new sap.ui.model.Filter("ID",sap.ui.model.FilterOperator.EQ, dropdownval)];
alert(oFilters);
sap.ui.getCore().byId("Products").bindRows("/Products",null,null,oFilters);
"Products" is the ID of the table.. i am filtering using ID entered in the dropdownbox..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
that is not about sap.m.SearchField, that is more about filtering logic in binding i guess.
in seach event assemble a filter array and pass it to filter function of the binding
var filterValue = oControlEvent.getParameter("query");
binding.filter([
new sap.ui.model.Filter("userName", sap.ui.model.FilterOperator.EQ, filterValue),
new sap.ui.model.Filter("userID", sap.ui.model.FilterOperator.EQ, filterValue)]);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maksim,
I tried but its not working fine.This is my function. Where I'm doing wrong.
InDetails_Search: function(oEvent) {
var tpmla = oEvent.getParameter("newValue");
var filters = new Array();
var oFilter = new sap.ui.model.Filter("Id", sap.ui.model.FilterOperator.Contains, tpmla);
filters.push(oFilter);
this.oList = sap.ui.getCore().byId("list");
this.oList.getBinding("items").filter(filters);
},
Can you show some code with what you have tried so far?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Kindly ask you to share your code snippet.
Regards,
Vladimirs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.