on 05-10-2017 8:16 AM
Hi,
I want to apply filter with * selection property in sap ui5. I couldn't get it. Normal fiter is working finely.
For suppose, If I put a filter on city name and write S*N*F*C* for filter. After filtering, It should get result : SAN FRANCISCO
Thanks in advance
Regards
Sukhram Bhamboo
The filter operators are:
sap.ui.model.FilterOperator.BTFilterOperator between.
sap.ui.model.FilterOperator.ContainsFilterOperator contains
sap.ui.model.FilterOperator.EndsWithFilterOperator ends with
sap.ui.model.FilterOperator.EQFilterOperator equals
sap.ui.model.FilterOperator.GEFilterOperator greater or equals
sap.ui.model.FilterOperator.GTFilterOperator greater than
sap.ui.model.FilterOperator.LEFilterOperator less or equals
sap.ui.model.FilterOperator.LTFilterOperator less than
sap.ui.model.FilterOperator.NEFilterOperator not equals
sap.ui.model.FilterOperator.StartsWithFilterOperator starts wit
You can choose to apply according to user entry but there is no default way to interpret * and get the results accordingly.
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Sukhram Bhamboo,
There is no redefine operator for this scenario .
Just create a custom filter and apply it to your list binding.
new sap.ui.model.Filter('<path on which filter needs to be applied>', <custom function >)
reference :
https://openui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.Filter.html#constructor
thanks
Viplove
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply, But this concept is not that much clear to proceed further.
Actually I am displaying table data on sap ui5 screen using odata services. Now I am applying filter with * selection for one of my table column.
So can you explain how custom filter can be built for it and what would be path just by an example?
Regards
Sukhram Bhamboo
Hi Sukhram ,
So you need to apply filter on that column binding .. lets say you have input field which filter your table data on the basis of city.
view
<Input placeholder = "Enter your filter" id="filterInput" />
<Button text = "Apply" press="onApplyFilter" / >
<Table id ="table" items="{path:'/resultSet'}">
<columns>
...
<Column >
<Text text="City"/>\
</Column>
...
<columns>
<items>
<ColumnListItem>
<Text text="{city}"></ColumnListItem></items>
</Table>
controller
onInit:function(){},
onApplyFilter:function(){
var fValue = this.getView().byId("filterInput").getValue();
var filters = [];
var filter = new sap.ui.model.filter("city",function(value){
var split = fValue.split("*");
for(var i=0;i<split.length;i++)
{
if(value.indexOf(split[i]) > -1)
{
var index = value.indexOf(split[i]) + split[i].length ;
value = value.substr(index);
}
}
if(i=== split.length)
{return true;}
else
{return false;}
});
filters.push(filter);
this.getView().byId("table").getBinding("items").filter(filters);
}
Note : the logic for the custom filter function might not be upto the mark .. but this will make you understand how we are writing the custom filter
thanks
Viplove
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.