question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sap.m.Tree - JsonModel - Filter - arrayNames

See original GitHub issue

OpenUI5 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

image

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
FiddleBecommented, Dec 22, 2017

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

0reactions
vdhnilscommented, Feb 26, 2020

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)

			oOutcomeTreeTable.getBinding("rows").filter(
				new Filter({
			        path: "_sOperation",
			        operator: "NE",
			        value1: "DELETE",
			    })
			);
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found