[转] flex tree ITreeDataDescriptor

原文链接: http://hi.baidu.com/liuyq188/blog/item/7f4eeeecbebccaddb21cb1b1.html

ITreeDataDescriptor接口
方法
addChildAt(parent:Object, newChild:Object, index:int, model:Object = null):Boolean
在指定索引处向节点添加子节点。
提供对子节点的访问,并返回子节点的集合视图(如果存在子节点)。
getData(node:Object, model:Object = null):Object
从节点中获取数据。
hasChildren(node:Object, model:Object = null):Boolean
测试非终止节点中是否存在子节点。
isBranch(node:Object, model:Object = null):Boolean
测试节点的终止性。
removeChildAt(parent:Object, child:Object, index:int, model:Object = null):Boolean
从指定索引处的节点中删除子节点。
import mx.controls.treeClasses.DefaultDataDescriptor;import mx.controls.treeClasses.ITreeDataDescriptor;
public class TreeDataDescriptor extends DefaultDataDescriptor implements ITreeDataDescriptor{
}
以前在操作Tree的时候,总是直接对Tree的dataProvider进行操作。后来发现dataDescriptor : ITreeDataDescriptor属性对Tree的操作会更方便。
dataDescriptor :是树使用数据描述符表示与数据相关的信息。

ITreeDataDescriptor:提供用于对 Tree 控件显示的数据集合执行分析和添加节点操作的方法的接口。

下边有一段使用的小函数:
private function toggleChildren (item:Object, tree:Tree, state:String):void

    if (item == null) {return;}
     else 
    {
     item.@state = state; 
    var treeData:ITreeDataDescriptor = tree.dataDescriptor;
     if (treeData.hasChildren(item)) 
        { 
            var children:ICollectionView = treeData.getChildren (item); 
            var cursor:IViewCursor = children.createCursor(); 
            while (!cursor.afterLast) {
                 toggleChildren(cursor.current, tree, state); 
                cursor.moveNext(); } 
        }
     }
}
smithfox | Wednesday 02 March 2011 at 4:25 pm | | UI        | Used tags: , ,

three comments

smithfox

还有两篇我的blog和flex tree相关:

http://www.smithfox.com/?e=85

http://www.smithfox.com/?e=155

smithfox, (URL) - 30-06-’11 15:50
Dior iPhone 6 Cases

While the Galaxy S6 sales figures offer a measure of good news for Samsung, the increased sales come largely at the expense of other Samsung smartphones—not Apple’s, says Counterpoint.

Dior iPhone 6 Cases, (URL) - 04-06-’15 14:04
Yeezy Boost 350 Oxford Tan

Both styles appear in a multi-color embroidered version, and in a green-and-white version that pays homage to Williams’ favorite summer footwear style: the Adidas Stan Smith.

Yeezy Boost 350 Oxford Tan, (URL) - 01-06-’16 14:40
(optional field)
(optional field)
为阻止垃圾广告, 请在提交评论前, 回答一个简单问题(Please answer an simple question)
Remember personal info?
Notify
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.