flex Tree xmlNode jsonData,更换treeData

news/2024/5/19 17:40:48 标签: Flex, json, XML
这里呈现出源码,查看一下结果。看一下json格式数据和xml格式数据的使用,还有就是更换数据后树的数据显示正常。
[quote]
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
initialize="initTree()"
>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
[Bindable]
public var open:Object = new Object();
[Bindable]

public var refreshData:Boolean = false;
[Bindable]
public var switchObj:Object = new Object();
[Bindable]

public var firstObj:Object = new Object();
[Bindable]

public var firstObj1:Object = new Object();
[Bindable]

public var firstObj2:Object = new Object();
[Bindable]

public var provider:String = "firstObj";

private function initTree():void

{

firstObj = new Object();
firstObj.label = "Foods";
firstObj.children = new Array();
firstObj1.label = "Fruits";
firstObj1.children = new Array();
firstObj2.label = "Oranges";
firstObj1.children[0] = firstObj2;
firstObj.children[0] = firstObj1;
switchObj = [
{label:'root1',children:[{label:"firstChilden"},{label:"secondChild"}]}
,
{label:'root2',children:[{label:"firstChilden"},{label:"secondChild"}]}
];
}

public function changeProvider():void
{
open = SampleTree.openItems;
refreshData = true;
if (provider == "firstObj")

{
SampleTree.labelField="label";
provider = "switchObj";
SampleTree.dataProvider = switchObj;
}
else if (provider == "switchObj")
{
provider = "xmlObj";
SampleTree.labelField="@label";
SampleTree.dataProvider = treeData;
}
else if (provider == "xmlObj")
{
provider = "firstObj";
SampleTree.labelField="label";
SampleTree.dataProvider = firstObj;
}
}

public function renderTree():void{
if(refreshData){

// Refresh all rows on next update.
SampleTree.invalidateList();
refreshData = false;
SampleTree.openItems = open;
// Validate and update the properties and layout
// of this object and redraw it, if necessary.
SampleTree.validateNow();
}

}
]]>
</mx:Script>
<mx:XMLList id="treeData">
<node label="Mail Box">
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
<node label="Personal"/>
</node>
<node label="Outbox">
<node label="Professional"/>
<node label="Personal"/>
</node>
<node label="Spam"/>
<node label="Sent"/>
</node>
</mx:XMLList>
<mx:Tree id="SampleTree" render="renderTree()" showRoot="true" width="250" dataProvider="{firstObj}" labelField="label" />

<mx:Button label="Change Data Provider" click="changeProvider()"/>
</mx:Application>


[/quote]

http://www.niftyadmin.cn/n/869523.html

相关文章

静态背景下运动目标检测 matlab_动态拉伸、静态拉伸你做对了么?

↑ 点击图片获得JOINFIT健身装备 ↑ “运动乃精神之砥柱&#xff0c;思想之动力&#xff01;”-----马库斯图留斯西塞罗拉伸对于很多肌友都不算陌生&#xff0c;人多人都喜欢在开始训练前做一些拉伸。但是有些人觉得训练之后进行拉伸太麻烦了&#xff0c;但其实拉伸非常关键&am…

C语言程序设计编制班排系统,C语言程序设计例题

C语言程序课程设计任务书一、题目每个同学可从下列给出的参考题目中任选一题完成&#xff0c;也可以自选题目。1.完成一个学生成绩管理系统。内容描述&#xff1a;设计四个类&#xff1a;学生基本信息&#xff1b;成绩表&#xff1b;班级表&#xff1b;课程表(描述课程信息&…

llinux jconsole监控内存泄漏_Flutter 上的内存泄漏监控

一、前言Flutter 所使用的 Dart 语言具有垃圾回收机制&#xff0c;有垃圾回收就避免不了会内存泄漏。在 Android 平台上有个内存泄漏检测工具 LeakCanary[1]&#xff0c; 它可以方便地在 debug 环境下检测当前页面是否泄漏。本文将会带你实现一个 Flutter 可用的 LeakCanary&am…

flex tree grid 综合页面

[quote] <?xml version"1.0" encoding"utf-8"?> <mx:Application xmlns:mx"http://www.adobe.com/2006/mxml" layout"absolute"> <mx:Style>Panel{fontSize:12pt;}Tree{fontSize:12pt;} </mx:Style> <mx…

c语言教程百度贴吧,【教程】C语言教程

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼在信息化、智能化的世界里&#xff0c;可能很早很早 我们就听过许多IT类的名词&#xff0c;C语言也在其中&#xff0c;我们侃侃而谈&#xff0c;到底C程序是什么样子&#xff1f;让我们先看简单的一个例子:123456789 #include /*引…

新标签页 chrome://newtab/_新电脑必备的软件及插件

每次换新电脑或者装完系统之后&#xff0c;我们都会装上常用的软件&#xff0c;下面我就推荐自己觉得不错的软件给大家&#xff0c;可能不使用所有人。一、软件篇谷歌浏览器谷歌浏览器可以说是世界上占有率最高的浏览器&#xff0c;它启动快、界面简洁、支持插件丰富&#xff1…

flex Tree 相册 json格式数据

[quote] <?xml version"1.0" encoding"utf-8"?> <!-- http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/ --> <mx:Application xmlns:mx"http://www.adobe.com/2006/mxml"…

evans pde 第三章_数学日记 第三章

数学日记第三章从尺子到山峰这是阳光明媚的一天&#xff0c;老师正在上课&#xff0c;而书菌正在偷偷的把玩着新买的尺子。这是一把锐角为30度和60度的直角三角形&#xff0c;崭新而通明。“咔嚓&#xff01;”一声&#xff0c;尺子被书菌不小心撇断了&#xff0c;成了不规则的…