cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Smart Table - Smart Filter: setFilterData & Searchfield

truckla
Explorer
0 Likes
3,138

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?

View Entire Topic
maheshpalavalli
Active Contributor

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