flex的tree根据属性值改变所有节点图标的方法
2008-06-03 13:46
357 查看
代码:
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
[Embed(source="assets/max_over.gif")] //这是图片的相对地址
[Bindable]
public var OKicon:Class;
[Embed(source="assets/close_over.gif")] //这是图片的相对地址
[Bindable]
public var NOicon:Class;
//设置不同图标
private function iconFun(item:Object):*
{
var xml:XML = item as XML;
if(xml.attribute("bool") == true)
return OKicon;
else if(xml.attribute("bool") == false)
return NOicon;
}
]]>
</mx:Script>
<mx:XMLListCollection id="datatree" >
<mx:source>
<mx:XMLList>
<node label="NO1" bool="false">
<node label="NO11" bool="false">
<node label="NO111" bool="false"/>
</node>
<node label="NO22" bool="true"/>
</node>
<node label="NO2" bool="true">
<node label="NO11" bool="false">
<node label="NO111" bool="false"/>
</node>
<node label="NO22" bool="true">
<node label="NO222" bool="false"/>
</node>
</node>
</mx:XMLList>
</mx:source>
</mx:XMLListCollection>
<mx:Tree id="tree" y="40" width="100%" height="100%" fontFamily="Arial" fontSize="12"
dataProvider="{datatree}" labelField="@label" iconFunction="iconFun" />
</mx:Application>
2/
可以复写Tree组件,在其单元格TreeItemRenderer内的commitProperties方法中进行判断然和赋值
icon.source = iconClass;
不知道可不可以。以前在TileList和DataGrid中用过
override protected function commitProperties():void
{
super.commitProperties();
if(super.data){
if(super.data.@label=="调度时间"){
super.removeChild(DisplayObject(icon));
var iconClass:Class = iconDesign;
icon = new iconClass();
addChild(DisplayObject(icon));
}
}
}
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
[Embed(source="assets/max_over.gif")] //这是图片的相对地址
[Bindable]
public var OKicon:Class;
[Embed(source="assets/close_over.gif")] //这是图片的相对地址
[Bindable]
public var NOicon:Class;
//设置不同图标
private function iconFun(item:Object):*
{
var xml:XML = item as XML;
if(xml.attribute("bool") == true)
return OKicon;
else if(xml.attribute("bool") == false)
return NOicon;
}
]]>
</mx:Script>
<mx:XMLListCollection id="datatree" >
<mx:source>
<mx:XMLList>
<node label="NO1" bool="false">
<node label="NO11" bool="false">
<node label="NO111" bool="false"/>
</node>
<node label="NO22" bool="true"/>
</node>
<node label="NO2" bool="true">
<node label="NO11" bool="false">
<node label="NO111" bool="false"/>
</node>
<node label="NO22" bool="true">
<node label="NO222" bool="false"/>
</node>
</node>
</mx:XMLList>
</mx:source>
</mx:XMLListCollection>
<mx:Tree id="tree" y="40" width="100%" height="100%" fontFamily="Arial" fontSize="12"
dataProvider="{datatree}" labelField="@label" iconFunction="iconFun" />
</mx:Application>
2/
可以复写Tree组件,在其单元格TreeItemRenderer内的commitProperties方法中进行判断然和赋值
icon.source = iconClass;
不知道可不可以。以前在TileList和DataGrid中用过
override protected function commitProperties():void
{
super.commitProperties();
if(super.data){
if(super.data.@label=="调度时间"){
super.removeChild(DisplayObject(icon));
var iconClass:Class = iconDesign;
icon = new iconClass();
addChild(DisplayObject(icon));
}
}
}
相关文章推荐
- Flex改变Tree树的节点图标和颜色
- FLEX中Tree默认展开所有节点
- Easyui Treegrid改变默认图标的方法
- FLEX中Tree默认展开所有节点
- Flex tree 节点遍历的方法
- Flex中树形节点的图标的设置的两种方法
- Easyui Treegrid改变默认图标的方法
- Flex tree 双击展开收起节点,更改图标设置
- Flex中如何通过Tree类的setItemIcon事件给Tree节点设置一个个性化图标
- Flex中如何去掉Tree控件默认文件夹图标、叶子节点图标
- flex----遍历树Tree,根据输入的名称搜索树节点,并展示该节点
- Phoenix Framework中为Tree的每个节点设置不同图标的方法
- extjs treepanel动态改变树节点的图标
- Extjs4中tree组件查找所有父节点和查找所有子节点的递归方法
- FLEX中Tree默认展开所有节点
- FLEX中Tree默认展开所有节点
- Flex两种改变树结点图标的方法
- Flex 自定义DataGrid实现根据条目某一属性值改变背景颜色
- FLEX中Tree默认展开所有节点
- Flex中在Tree绑定数据后自动展开树节点的方法