cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Table - Smart Filter: setFilterData & Searchfield

08-10-2020 11:46 AM
truckla Explorer
3219 views 1 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

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?

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

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

Answers (0)