Filter support for nested array (attributes)
See original GitHub issueI am using the 1.48 version. I have a list that is created based on a factory function (two different kind of cells)
Let’s say the json like this (nested):
[
{ name: "a",age:"12"},
{ name: "b",age:"14"},
{ group: "groupB", people: {[ { name: "z",age:"14"}, { name: "s",age:"16"}] }},
{ name: "c",age:"16"},
{ group: "groupA", people: {[ { name: "e",age:"14"}, { name: "f",age:"16"}] }},
{ name: "d",age:"18"}
]
In the documentation there is no explanation for how to filter a nested result…
// returns entries without nested people
var oFilter = new Filter("name", FilterOperator.EQ, sName),
but how can I get the group back that contains also a Name value ?
// returns nothing
var oFilter = new Filter("people.name", FilterOperator.EQ, sName),
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (1 by maintainers)
Top Results From Across the Web
JS (ES6): Filter array based on nested array attributes
You can use filter() with some() method to check if some of the objects in animals ...
Read more >Filtering an Array of Nested Arrays and Objects Using Angular ...
The purpose of this function is to identify all the nested objects and and arrays in the parent object, delete the nested object...
Read more >Nested filter by one item from array not every - Open Q&A
Hello, I have index of products, each product has variants. I am trying to filter by attributes of variants. Structure of product looks ......
Read more >Nested Array: Filter on a String [] /Map doesn't return results as ...
Problem is i am not able to achieve the filter working properly. I did tried to have the below properties as Map and...
Read more >Segment and filter against complex arrays and JSON
In the past, you weren't able to create segments or use complex JSON attributes (arrays, nested objects, and arrays of objects) in filters, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @kyakubi ,
it’s not very clear whether your filter is applied to a JSONModel or a ODataV2Model. Therefore I will explain a bit about the nested filtering on both models.
The OData Version 2 supports filtering on navigation property only when the navigation property is NOT a collection.
The URL example in a reply from @ThePlenkov works because the relation between “Address” and one “Suppliers” is 1:1 and not N:1.
If the navigation property is a collection (like in your example), the OData Version 2 doesn’t support filtering on its property. Please see details here: https://stackoverflow.com/a/33218540
The filtering on a JSONListBinding doesn’t support the nested filtering either. You have to use a custom filtering function and filter the items manually as you have already mentioned in your last reply.
Best regards, Jiawei
@stephania87 As I understand, what @kyakubi wants is to use V2 filter like this:
/Suppliers?$filter=Address/City eq ‘Redmond’
This URL is described in version 2.0: http://www.odata.org/documentation/odata-version-2-0/uri-conventions/