sap.m.Tree - JsonModel - Filter - arrayNames
See original GitHub issueOpenUI5 version: Detected in 1.48, but presumably in all versions since 1.44
Browser/version (+device/version): All browsers and devices
URL (minimal example if possible): https://embed.plnkr.co/bCOxJgLiQ6YRgKjhMsdq/
Steps to reproduce the problem: If you create hierachical json model with arrays
new JSONModel([ {key:"node1", text:"bla", children:[...]},
{key:"node2", text:"moo", children:[...]} ]
and you assign this to a Tree:
items:{path:'/', parameters{ arrayName:['children']} }
Filtering won’t work anymore.
The reason fir this lies in the ClientTreeBinding method getNodeContexts
If your node is an array “aChildArray = oNode[sArrayName];” will not work. this assumes that your model is a hierarchical object, instead of an array.
if however you could add
if(oNode instanceof Array){
oNode.forEach(function(oItem){
aChildArray = oItem[sArrayName];
...
})
Than filtering would also work on Array based json models.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Tree table filtering with json model is not working
I am having tree table (sap.ui.table.treetable) which has been binded with JSON model. there is already open question asked by some one else ......
Read more >Display only parts of a JSON-Model in a sap.m.Tree
What you are looking for is the parameter arrayNames from sap.ui.model.json.JSONTreeBinding. Bind your items like this:
Read more >Step 4: Filtering, Sorting, and Counting - SAPUI5 SDK
In this step, we add features to filter, sort, and count the user data by using the ... "sap/ui/model/FilterType", "sap/ui/model/json/JSONModel" ], function ...
Read more >SAPUI5 Data Binding Examples - Timo Denk
App", { onInit: function () { var model = new sap.ui.model.json.JSONModel(); model.setData({ arrayName: [ { name: "First Item", ...
Read more >FHIRTreeBinding.js - OpenUI5-FHIR - API Documentation
Filter | sap.ui.model.Filter[]} [aFilters] The dynamic application filters to be used initially (can be either a filter or an array of 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
Ahh, so if the node IS an array, you first store the subcontext of the node itself, and then recursively process each item in the array. that’s an elegant fix. and it solves my (non-prio) issue of having duplicate subcontexts
a second issue I faced after posting my proposal, was the iSizeLimit. I had a tree with 200 items, and apparently there’s a default iSizeLimit of 100. I overcame that issue by setting the iSizeLimit directly on my model to 99999. But wouldn’t it be better if there was a parameter that let’s you ignore any sizelimit? (eventhough I agree that performance can be severly affected)
Thanks for taking this up
PS: can you also update the doco of the sap.m.tree with the parameters? I only found out about them by diving deep into the debug-code.
PPS: if a patch can be made available for 1.46, 1.48, 1.50 and up, that would be great! We have a couple of projects still on 1.46 because of compatibility issues
this problem still seems to be happening in SAPUI5… i can solve it by applying filtering from the controller instead of the view… (in the view the filter has no effect, due to arrayNames)