on 2013 Oct 10 8:01 AM
Hi there, I would like to know, if someone has managed to implement a search in the DataSet control, that works like the suggest event in the normal searchField? The DataSet has only a search event, that get fired after hitting "enter".
Any suggestions? Thx
Request clarification before answering.
Hi,
Put following code in the search event
var sQuery = oEvent.getParameter("query");
var oBinding = oDataSet.getBinding("items");
oBinding.filter(!sQuery ? [] : [new sap.ui.model.Filter("title", sap.ui.model.FilterOperator.Contains, sQuery)]);
oDataSet.setLeadSelection(-1);
Here you have an example:
https://sapui5.hana.ondemand.com/sdk/#test-resources/sap/ui/ux3/demokit/DataSet.html
Kind regards,
Wouter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Wouter, thank you for the reply, Your code is for searching the data set and it's already in and working. But my problem was the "search" event itself. It get fired after pressing the ENTER key and I was looking for a solution to make it work after entering a charachter. I'm missing a "suggest" event.
Kind regards, Chis
One way to do that is to create a new search object
sap.ui.commons.SearchField
and implement the attachSuggest method
something like this
var search = new sap.ui.commons.SearchField(
"mySearch", {
enableListSuggest : false,
enableClear : true,
startSuggestion : 0,
value : "Search"
});
search.attachSuggest(function(oEvent) {
oController._searchMe(oEvent
.getParameter("value"));
}, oController)
in controller
_searchMe = function (query) {
//get DS object and apply the filter you mentioned above
//filtering will be triggered be on a keystroke
}
User | Count |
---|---|
89 | |
11 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.