Current Position:Home > How to apply a Filter on JSONModel for a Table data

How to apply a Filter on JSONModel for a Table data

Update:11-30Source: network consolidation
Advertisement
I have a table and search text box. Now when users types in something I want to filter the Table Data which is JSONModel.
There are several columns in the JSONModel and the search string should check against each column.
If columns are Date then ignore if they are numeric convert to String and check against value.
How can I achieve this?

The Best Answer

Advertisement
Hi Chandrashekhar,
Thanks for your reply it solves half of my problem.
Now if I want to have a OR condition for Filters applied on lastName and firstName column i.e. the search string should either exist in lastName or firstName return me all rows which satisfies the search string filter then how do I do it?
I tried the following by adding one more filter but I guess it creates AND condition between these filters
oTable.getBinding("rows").filter([new sap.ui.model.Filter("lastName", "StartsWith", sValue),
                                             new sap.ui.model.Filter("firstName",StartsWith",sValue)]);
I also observed that in the current code the filter is applied on lastName column but when you search the next column shows filter icon is this a bug?
Please refer screenshot