flexlib的treeGrid用法

为了使用treeGrid,通常你需要定义自己的DataDescriptor和data model,下面是一个案例.

	public class HierarchySearchResultVO
{
public function HierarchySearchResultVO(){
this._id=UIDGenerator.createUID();
}

/**
* An unique identifier of the created HierarchySearchResultVO object.
*/
[Transient]
private var _id:String;

public function get id():String{
return this._id;
}

public function set id(value:String):void{
this._id=value;
}

/**
* If not a summary record, it should have a parent.
*/
[Transient]
public var parent:HierarchySearchResultVO;

/**
* Indicates whether the record shows at summary level or detail level in a treeGrid.</br>
* True denotes a summary record, false denotes detail record, default is false.
*/
[Transient]
public var isSummaryRecord:Boolean=false;

/**
* Only applicable to summary record.
* Indicates whether the summary record has got its children from server.</br>
* True denotes the summary record has already got its children from serve;</br>
* False denotes not yet.
*/
[Transient]
public var hasChildrenReturned:Boolean=false;

/**
* Indicates whether the summary record itself or detail record is checked,
* isAllSeleceted and isPartSelected are used to indicate whether the children of
* the summary record are checked, they don't indicate the check status of the summary record itself.
*/
[Transient]
public var isSelected:Boolean=false;

/**
* Indicates whether all the children records of a summary record have been checked,
* only used for a summary record, should be exclusive with isPartSelected.
* If isAllSelected=false and isPartSelected=false means none of the children records have been checked.
*/
//[Transient]
//public var isAllSelected:Boolean=false;

/**
* Indicates only part of the children records of a summary record have been checked,
* only used for a summary record, should be exclusive with isAllSelected.
* If isAllSelected=false and isPartSelected=false means none of the children records have been checked.
*/
[Transient]
public var isPartSelected:Boolean=false;

/**
* This property name should be same as what we defined in HierarchySearchResultDataDescriptor,
* element should be object of HierarchySearchResultVO, not SearchResultVO.
*/
[Transient]
public var childrenCollection:ArrayCollection;

public var searchResultVO:SearchResultVO;
}



	/**
* Used to parse the data of the TreeGrid
*/
public class HierarchySearchResultDataDescriptor extends DefaultDataDescriptor
{
public function HierarchySearchResultDataDescriptor()
{
super();
}

override public function getChildren(node:Object, model:Object=null):ICollectionView
{
return node.childrenCollection;
}

override public function hasChildren(node:Object, model:Object=null):Boolean
{
return node != null && node.childrenCollection != null && (node.childrenCollection as ArrayCollection) != null && (node.childrenCollection as ArrayCollection).length > 0;
}

override public function isBranch(node:Object, model:Object=null):Boolean
{
return (node as HierarchySearchResultVO).isSummaryRecord;
}

override public function getData(node:Object, model:Object=null):Object
{
return node;
}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值