Skip to Content
1

Search on worklist does not work in SAPUI5 Fiori Template Application

Oct 21, 2016 at 08:14 AM

144

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Kanika Malhotra Feb 20, 2017 at 05:24 AM
0

Hi @Mahdi Jaberzadeh Ansari

Did you find any solution to this?

Thanks

Kanika

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0