on 07-31-2018 10:02 PM
Hello:
I am trying to create an sap.ui.model.Filter for a list of customers, on the value of an expanded element. Specifically, a Customer has multiple locations, and the US State is one of the elements of the location. The OData looks something like this:
[{"name": "Customer A", "locations": [{"city": "Los Angeles", "state": "CA"}, {"city": "Dallas", "state": "TX"}]}, {"name": "Customer B", "locations": [{"city": "Boston", "state": "MA"}, {"city": "San Francisco", "state": "CA"}]}]
The filter would be given a state, and return true if the customer has a location in that state
I think that filter (with a hard-coded value, obviously) would look something like this:
oFilters.push(new sap.ui.model.Filter({
path: "locations",
test: function(oValue) {
var oLocations = oValue.getModel();
for (var oLocation in oLocations) {
if (oLocation.getProperty("state") === "CA") {
return true;
}
}
return false;
}
}));
When I run the filter, I should get back [true, true] and then both "Customer A" and "Customer B" would be included in the results. I get nothing back (so everything passes) and I can't trace its actions.
Does anyone have experience with this? If you are wondering, this is trying to simulate the OData v4 'ANY' filter.
you can write a debugger statement inside and check the data. I am not sure how you will get the data in the function parameter oValue and I think you will not get the model there, instead you will have the values. or that particular line. Better check in debugging, put a debugger statement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.