如何在 sapui5 中实现 TreeTable [英] How to implement TreeTable in sapui5

查看:46
本文介绍了如何在 sapui5 中实现 TreeTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的模型

[ {"name":"Main 1","description":"main1 Description",
         "children": [{
               "name": "SUB 1",
               "description": "SUB 1 Description",
               "children":[
                    {
                        "name": "SUB 1.1",
                        "description": "SUB 1.1 Description"
                    },
                    {
                        "name": "SUB 1.2",
                        "description": "SUB 1.2 Description"
                    }         ]
                }],
                "parent":[{"name": "parent sub"}]
            },
   {"name":"Main 2","description":"main2 Description",children:[],parent:[]},
   {"name":"Main 3","description":"main3 Description",children:[],parent:[]},
   {"name":"Main 4","description":"main4 Description",children:[],parent:[]}
 ]

我想显示 namedescription 属性."children" 属性中的内容应该是行中的一个子级别,我不想在这个树表中显示 "parent" 内容.如何从树表中限制 "parent" 属性.

and i want to display name and description property. The contents in the "children" property should be a sub-level in the row, and i don't want to display "parent" content in this tree table. how can i restrict "parent" property from the tree table.

推荐答案

TreeTable 使用的带有 JSONModel 或 XMLModel 的 sap.ui.model.ClientTreeBinding 支持参数 arrayNames.此参数需要一个模型属性名称数组,该数组将创建一个子级别(如果包含一个对象).

The sap.ui.model.ClientTreeBinding used by the TreeTable with a JSONModel or XMLModel supports the parameter arrayNames. This parameter expects an array of the model property names that will create a sublevel (if containing an object).

所以在你的例子中你应该使用这样的东西:

So in your example you should use something like this:

treeTable.bindRows({path: '/pathToData', parameters: { arrayNames: ['children'] }});

或在 XMLView 中:

or in XMLView:

<TreeTable rows="{path: '/pathToData', parameters: { arrayNames: ['children'] } }" >
...
</TreeTable>

除了一个例子.您可以找到示例的源代码 在 openui5 github 中.

Theres not much to find in the documentation about this except for one example. You can find the source for the example in the openui5 github.

这篇关于如何在 sapui5 中实现 TreeTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆