Skip to content

Commit

Permalink
Added everything for Step 12: Adding a Search
Browse files Browse the repository at this point in the history
  • Loading branch information
wridgeu committed Jun 7, 2020
1 parent a743c0e commit 240f562
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
30 changes: 24 additions & 6 deletions webapp/controller/Worklist.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ sap.ui.define(
"sap/ui/model/json/JSONModel",
"sap/m/library",
"../model/FlaggedType",
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
],
function (BaseController, JSONModel, mobileLibrary, FlaggedType) {
function (
BaseController,
JSONModel,
mobileLibrary,
FlaggedType,
Filter,
FilterOperator
) {
"use strict";

return BaseController.extend("com.mrb.UI5-Testing.controller.Worklist", {
Expand Down Expand Up @@ -50,11 +59,6 @@ sap.ui.define(
oViewModel.setProperty("/tableBusyDelay", iOriginalBusyDelay);
});
},

/* =========================================================== */
/* event handlers */
/* =========================================================== */

/**
* Triggered by the table's 'updateFinished' event: after new table
* data is available, this handler method updates the table counter.
Expand Down Expand Up @@ -123,6 +127,20 @@ sap.ui.define(
postId: oEvent.getSource().getBindingContext().getProperty("PostID"),
});
},

onFilterPosts: function (oEvent) {
// build filter array
var aFilter = [];
var sQuery = oEvent.getParameter("query");
if (sQuery) {
aFilter.push(new Filter("Title", FilterOperator.Contains, sQuery));
}

// filter binding
var oTable = this.byId("table");
var oBinding = oTable.getBinding("items");
oBinding.filter(aFilter);
},
});
}
);
2 changes: 2 additions & 0 deletions webapp/view/Worklist.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<headerToolbar>
<Toolbar>
<Label id="tableHeader" text="{worklistView>/worklistTableTitle}"/>
<ToolbarSpacer />
<SearchField id="searchField" width="auto" search=".onFilterPosts" />
</Toolbar>
</headerToolbar>
<columns>
Expand Down

0 comments on commit 240f562

Please sign in to comment.