Skip to Content
avatar image
Former Member

Search on worklist does not work in SAPUI5 Fiori Template Application

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Feb 20, 2017 at 05:24 AM

    Hi @Mahdi Jaberzadeh Ansari

    Did you find any solution to this?

    Thanks

    Kanika

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.