on 11-28-2013 11:01 AM
Hi All,
I am currently implementing a DataSet application.
According to the dev guide (https://sapui5.netweaver.ondemand.com/sdk/#test-resources/sap/ui/ux3/demokit/DataSet.html)
I managed that the filter is working fine, as described above.
search: function search(oEvent) {
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);
},
By this solution it is only possible to search for a specific bound property/attribute. Now I would like to search for ALL attributes.
E.g: "title" and "systemtype" at the same time.
Let say there is an item with title="NetWeaver Administrator" and another one with systemtype= "NWDI"
So when I would trigger the search with "N" all both items should be displayed....
when triggering the search with "NW" only one item should be displayed.
In words: I want to search that either matches the title-value or the systemtype-value.
I tried following
search: function search(oEvent) {
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),
new sap.ui.model.Filter("systemtype", sap.ui.model.FilterOperator.Contains, sQuery)
]);
oDataSet.setLeadSelection(-1);
},
But this seems to display only those items where "title" AND "systemtype" matches.
Does anyone have an idea how to archieve this.
Regards,
Jens
Hi Jens,
not really sure, but try to add 2 "systemtype" filters.
see an example https://sapui5.hana.ondemand.com/sdk/#test-resources/sap/ui/core/samples/databinding/DataBindingTree...
Regards
Konstantin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
* new sap.ui.model.Filter(aFilters, bAnd);
*
* aFilters is an array of other instances of sap.ui.model.Filter. If bAnd is set all filters within the filter will be ANDed else they will be ORed.
oBinding.filter( |
!sQuery ? [] : [
new sap.ui.model.Filter( |
[
new sap.ui.model.Filter("title", sap.ui.model.FilterOperator.Contains, sQuery),
new sap.ui.model.Filter("category", sap.ui.model.FilterOperator.Contains, sQuery)
],
false)
] | ||||
); |
Hi Maksim,
yes, this is the solution. Thank you!
I finally found this hint in the developer guide as well, but I really needed to search for it 😉
I figured out, that there is a bug in SAPUIVersion 1.12.5 and filtering is not working as desired.
But it is working now with 1.16.6.
Puahhh!!!
Got my Problems solved now. Perfekt!
Regards,
Jens
User | Count |
---|---|
83 | |
11 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.