cancel
Showing results for 
Search instead for 
Did you mean: 

Search on worklist does not work in SAPUI5 Fiori Template Application

Former Member

Hi SAPUI5 developers,

I made a Firori Worklist project inside of WebIDE. I connected it to an OData server and selected SAPUI version 1.38 as default.

It shows the worklist correctly and I can press on items and move between views and visit the object especially.

So everything seems to work fine.

The only thing that is not working is the search box. Its event is triggered whenever I type something inside it and press enter, but it does not filter anything.

The functions that are called are as follow:

onSearch: function(oEvent) {

        if (oEvent.getParameters().refreshButtonPressed) {
            // Search field's 'refresh' button has been pressed.
            // This is visible if you select any master list item.
            // In this case no new search is triggered, we only
            // refresh the list binding.
            this.onRefresh();
        } else { 
            var oTableSearchState = [];
            var sQuery = oEvent.getParameter("query");

            if (sQuery && sQuery.length > 0) {
                oTableSearchState = [new Filter("ZBrandName", FilterOperator.Contains, sQuery)];
            } 
            this._applySearch(oTableSearchState);
        }

    },
     /**
     * Internal helper method to apply both filter and search state together on the list binding
     * @param {object} oTableSearchState an array of filters for the search
     * @private
     */
    _applySearch: function(oTableSearchState) {
        var oTable = this.byId("table"),
            oViewModel = this.getModel("worklistView");
            console.log(oTable);
        oTable.getBinding("items").filter(oTableSearchState, "Application");
        // changes the noDataText of the list in case there are no filter results
        if (oTableSearchState.length !== 0) {
            oViewModel.setProperty("/tableNoDataText", this.getResourceBundle().getText("worklistNoDataWithSearchText"));
        }
    },

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi @Mahdi Jaberzadeh Ansari

Did you find any solution to this?

Thanks

Kanika

Former Member
0 Kudos

Yes I found the solution. I mixed up the JSONModel with ODataModel. In almost all of the examples people used JSONMOdel which mean search and filter done in front end. While when we use OData Model the search and filter sends to the backend and has to be implemented there.