当前位置:首页 > 开发 > Web前端 > 前端 > 正文

flexlib的treeGrid用法

发表于: 2012-11-30   作者:darrenzhu   来源:转载   浏览:
摘要: 为了使用treeGrid,通常你需要定义自己的DataDescriptor和data model,下面是一个案例. public class HierarchySearchResultVO { public function HierarchySearchResultVO(){ this._id=UIDGenerator.createUID(); }
为了使用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;
		}
		
	}

flexlib的treeGrid用法

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号