Display only parts of a JSON-Model in a sap.m.Tree

Viewed 236

I have a UI5-JSON-Model and want to display it in a tree. But I want to display not the whole structure, but only a subset. Say I have the following model:

{
  "nodes": [
    {
      "text": "Leaf 1",
      "additionalStuff": [
        {
          "element": "blue"
        },
        {
          "element": "green"
        }
      ]
    },
    {
      "text": "Subtree",
      "nodes": [
        {
          "text": "Leaf in Subtree"
        }
      ]
    },
    {
      "text": "Leaf 2"
    }
  ]
}

I want to display the nodes and the text, but not the additionalStuff. But the picture I get is the following:

Screenshot of my sample tree

How can I tell the tree to ignore the additionalStuff?

Live Example

1 Answers

What you are looking for is the parameter arrayNames from sap.ui.model.json.JSONTreeBinding.

Bind your items like this:

items="{path: '/nodes', parameters: {arrayNames: ['nodes', 'text']}}"

For complex expression bindings, you have to configure it in your bootstrapping.

data-sap-ui-compatVersion="edge"

Complex syntax is automatically activated when the compatVersion is set to edge or to version 1.28 or higher.

Here is the documentation for Configuration Options and URL Parameters.

Related