如何知道 AdvancedDatagrid 中是否有子项/节点 [英] How to know if there are sub items/nodes in an AdvancedDatagrid

查看:23
本文介绍了如何知道 AdvancedDatagrid 中是否有子项/节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总结:如果节点分支(级别 1)具有零个数据项,我该如何删除它?如果它的子项被(空的或已被)删除,反过来也删除更高级别 0 的节点?

在互联网上进行大量搜索后,我仍然需要知道如何确定 AdvancedDatagrid 或节点"是否包含子节点.如何知道它是空的还是有东西"?有了它,我就可以用我的函数过滤它..(解释如下):

After much searching on the internet I still need to know if how to find out if an AdvancedDatagrid or a "node" contains children. How to know if it's empty or has "something"? With it, I will be able to filter it with my function.. (Expalined below):

首先我为我的英语不好道歉.

Firstly I apologize for my bad english.

我有一个 AdvancedDatagriddataProvider 一个 ArrayCollection.我使用 GroupingCollection2 将我的数据分组到节点中.

I have an AdvancedDatagrid with for dataProvider an ArrayCollection. I use a GroupingCollection2 to group my data in nodes.

我在 AdvancedDatagriddataProviderICollectionView 上使用 filterFunction.它有效!

I use a filterFunction on a ICollectionView of dataProvider of the AdvancedDatagrid. It works!

我的分组数据示例:

- Node level 0
  -- Node level 1
     ++ Data 1
     ++ Data 2
     ++ Data 3
  -- Node level 1
     ++ Data 4
     ++ Data 5
- Node level 0
  -- Node level 1
     ++ Data 6
     ++ etc..

我只过滤叶子"(数据子节点)上的数据.在我的过滤功能之后,数据项被正确过滤了!

I filter only the data which are on "leafs" (Data sub nodes). After my filter function, Data items are correctly filtered!

过滤后的结果示例:数据 2数据 4数据 5数据 6:

Example of results after filtering these: Data 2, Data 4, Data 5, Data 6 :

- Node level 0
  -- Node level 1
     ++ Data 1
     ++ Data 3
  -- Node level 1

- Node level 0
  -- Node level 1

例如具有不需要的"数据的节点被正确过滤掉.

For example nodes with "unwanted" Data are correctly filtered out.

但我也想过滤掉那些现在空"的节点!!也就是说如果节点分支(级别 1)的叶子项为零,我如何删除它?如果删除后的子分支总数为零,则还删除节点级别 0?

BUT I want to filter out those now "empty" nodes too!! Thats is to say How can I remove a node branch (level 1) if it has zero leaf items? And in turn also remove a Node level 0 if it's total sub-branches are zero after they've been removed?

我想要这个列表:

- Node level 0
  -- Node level 1
     ++ Data 1
     ++ Data 3

提前致谢.

(ps:如果我不够具体,我可以提出问题)

(ps: i'm available for questions if I was not enough specific)

推荐答案

我终于想通了!!!

我的秘诀是当我使用 GroupingCollection2 对数据进行分组时,我将一些新闻分组传递给节点(使用 groupingField).但是节点的itemRenderer不显示消息.并且在这些新闻上使用 substring 系统,我在我的 filterFucntion 中使用它们.

My secret is when I group data with GroupingCollection2 I pass to the node grouped some news (with a groupingField). But news are not showed by the itemRenderer of the node. And with a system of substring on these news I use them in my filterFucntion.

关于基本"分组和我的分组之间差异的说明:事实上,当您对数据进行分组时,创建的节点仅包含创建它们的字段.

Explanations about difference between "basic" grouping and my grouping : In fact when you group data, created nodes contain only the field whereby they've been created.

例如我的数据有 4 个字段:域、测试、状态、版本.我按域对它们进行分组 &通过像这样的测试(这是我的数据显示方式的示例,每个级别的项目渲染器都不同).

For instance my data have 4 fiels : domain, test, status, version. I group them by domain & by test like this (it's a example of how my data are showed, with an item renderer different for each level).

在数据变成这样之前:

- domain 1
  -- test 1
     ++ status/version 1
     ++ status/version 2
  -- test 2
     ++ status/version 3
     ++ status/version 4
- domain 2 etc..

但是在叶子(++行)上,分组后,还有分组"字段的数据.即测试和域字段!

But on the leafs (++ rows), after grouping, there is yet data of the fields "grouped". Namely test and domain field!

基本分组后的总结:

  • 节点级别 0 中的数据:域
  • 节点级别 1 中的数据:测试
  • 叶级别 2 中的数据:域/测试/状态/版本.

经过我分组后显示的数据都是一样的.

但是

在我分组之后:

  • 节点级别 0 中的数据:域
  • 节点级别 1 中的数据:域/测试
  • 叶级别 2 中的数据:域/测试/状态/版本.

多亏了这一点,我可以使用我的过滤器函数(使用子字符串系统)知道每个节点的父节点,并且在过滤器后节点为空时,同样可以知道!

Thanks to that I can with my filter function (using substring system) know the parent of each node and by the same occasion if the node is empty after a filter!

我想我一点都不清楚,我很抱歉..这真的很复杂,所以如果有人遇到类似的问题,我准备回答更具体的问题!!

这篇关于如何知道 AdvancedDatagrid 中是否有子项/节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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