on 08-19-2016 4:32 AM
Hi All,
I have a table which has binding to a Odata Model. I have a search field at the top of the table which should filter my table values.
var sField = "profam"; | ||||
var sQuery = oEvent.getParameter("query");
var filters = new sap.ui.model.Filter(sField, sap.ui.model.FilterOperator.Contains, sQuery);
// update list binding
var list = this.getView().byId("table"); |
var binding = list.getBinding("items"); |
binding.filter(filters);
But the table is not filtering with the search criteria.
Does Client Side Filter works for Odata model or we need to filter in the Odata ?
Thanks
Gopi
Hi Gopi,
OData Model is a Server-Side Model and it supports server-side filtering.
But from 'v2' version of OData Model, you have an option to set the mode to 'Client' / 'Server' / 'Auto' depending on your use case.
You have to set the mode, when you're binding items to table, for example:
oTable.bindItems({
path: 'yourBindingPath',
parameters: {
mode: sap.ui.model.odata.OperationMode.Client
}
});
Regarding your issue: Since you didn't set any mode, it automatically picks 'Server' as the mode and does the filtering on server side. Your code looks fine. But, can you check the developer console and see if there are any errors?
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sai,
I tried as below. The table gets refreshed but data is not filtered.
var sQuery = oEvent.getParameter("query");
var sField = "Lbiprofam";
var oFilters = new sap.ui.model.Filter(sField, sap.ui.model.FilterOperator.Contains, sQuery);
var oTable = this.getView().byId("table");
oTable.bindItems("/ZPRODFAM_HCISet",ItemTemplate, sap.ui.model.odata.OperationMode.Client,oFilters );
Am I missing anything here?
Thanks Gopi
Gopi,
You have to set the mode at first when you bind items to table for the first time. No need to do it again when you filter the table.
Your below code is good (Actual Question Code), just set a break point and see where it is going wrong.
var sField = "profam";
var sQuery = oEvent.getParameter("query");
var filters = new sap.ui.model.Filter(sField, sap.ui.model.FilterOperator.Contains, sQuery);
// update list binding
var list = this.getView().byId("table");
var binding = list.getBinding("items");
binding.filter(filters);
Regards,
Sai.
User | Count |
---|---|
83 | |
11 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.