使用数组填充 Flex 中的树

发布于 2024-09-20 00:24:09 字数 237 浏览 1 评论 0原文

您好,我所需的树结构如下

a  -- b -- d
   |  |
   |  |
   |  -- e
   -- c

我的字符串数组如下

a/b,c 日/日,日 d/ e

其中 / 之前的组件代表父级,相应父级的子级由 分隔,

任何人都可以为我提供为该层次结构创建数组集合的逻辑,以将其设置为我的树的数据提供者。

感谢和问候

Hi my required tree structure is as follows

a  -- b -- d
   |  |
   |  |
   |  -- e
   -- c

I have my string array as follows

a/b,c
b/d,e
d/
e

where the component before / represents parent and the children of the corresponding parent are separated by ,

Can anyone provide me the logic to create a array collection for this hierarchy to set as dataprovider to my tree.

Thanks and regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨与橙与城 2024-09-27 00:24:09

这是总体思路。 (我不会输入所有节点)另一种方法是创建一个具有标签和子属性的对象,而不是使用对象动态创建所有这些。希望有帮助。

var dp:Array = new Array();

dp[0] = new Object();
dp[0].label = "a";
dp[0].children = new Array();
dp[0].children[0] = new Object();
dp[0].children[0].label = "b";

myTree.dataProvider = dp;

Here's the general idea. (I'm not going to type all of the nodes out) Another approach is to create an object that has label and children properties rather than creating all of this dynamically with Objects. Hope that helps.

var dp:Array = new Array();

dp[0] = new Object();
dp[0].label = "a";
dp[0].children = new Array();
dp[0].children[0] = new Object();
dp[0].children[0].label = "b";

myTree.dataProvider = dp;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文