on ‎2020 Aug 10 10:46 AM
Hi!
I want the smartTable filters to be set at startup. I want to set this in the controller because I get certain IDs that I want to set as filters.
Also, the filter bar (next to the start button) is grayed out and I don't know why.
I know that you can set the filter somehow with setFilterData but I can't get it to work and I can't find a complete example for this.
I tried this:
var oTableData = this.getView().byId("sTable").getBinding("items");
var sortedData = oTableData.sSortParams;
var filtersData = oTableData.sFilterParams;
var list = this.getView().byId("sTable");
var binding = list.getBinding("items");
var query = oEvent.getParameter("query");
if (!query) {
binding.filter([]);
} else {
binding.filter([new sap.ui.model.Filter([
new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.Contains, query),
new sap.ui.model.Filter("gender", sap.ui.model.FilterOperator.Contains, query)
], false)]);
}
but it doesn't work, the problem starts already that it doesn't find bindings with "items".
Maybe someone has a good example for me with View and Controller?
Request clarification before answering.
You have to use rebind event handler and have to handle the filters there, check the below answer
https://stackoverflow.com/questions/50390460/sapui5-auto-bind-smart-table-with-filters
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.