读书人

tree的xml数据格式,该如何处理

发布时间: 2012-02-25 10:01:48 作者: rapoo

tree的xml数据格式
我现在生成一个tree,xml格式是,下面这样的是可以把树显示出来

XML code
  <xml>    <node name='根节点'>       <node name='节点1' />       <node name='节点2'>    </node>  <xml>

但我现在想在节点上配置一些信息,记录在节点,例如人员,而且是多个人员,如节点1:
XML code
  <xml>    <node name='根节点'>       <node name='节点1'>          <employees>            <employee name='张三' />            <employee name='李四' />          </employees>       </node>       <node name='节点2'>    </node>  <xml>

如果我按上面的xml格式,我的树也把<employees>下面的用户也显示出来,如何让我的树只显示xml中位node的数据,就是下列样式:
根节点
|____节点1
|____节点2

[解决办法]
定义个类继承DefaultDataDescriptor,重写方法getChildren
比如:
XML code
override public function getChildren(node:Object, model:Object=null):ICollectionView{            var result:ICollectionView = super.getChildren(node, model);                        var children:ListCollectionView;                        if(result is ListCollectionView){                children = new ArrayCollection();                children.list = (result as ListCollectionView).list;                }else{                children = new ArrayCollection([]);                var cursor:IViewCursor = result.createCursor();                while(cursor.current){                    children.addItem(cursor.current);                    cursor.moveNext();                }            }            children.filterFunction = this.filterFunction;            children.refresh();            return children;        } 

读书人网 >flex

热点推荐