欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Flex 优化Renderer(不使用HGroup) 博客分类: flex renderer优化datagrid 

程序员文章站 2024-03-25 15:27:40
...
package 
{

	import mx.controls.dataGridClasses.DataGridListData;
	import mx.controls.listClasses.BaseListData;
	import mx.controls.listClasses.IDropInListItemRenderer;
	import mx.controls.listClasses.IListItemRenderer;
	import mx.core.UIComponent;
	import mx.events.FlexEvent;

	public class BaseRenderer extends UIComponent implements Tabable, IListItemRenderer, IDropInListItemRenderer
	{
		private var _dataIndex:int=-1;
		private var _listData:DataGridListData;
		private var _data:Object;

		public function BaseRenderer()
		{
			super();
		}

		public function get dataIndex():int
		{
			return _dataIndex;
		}

		public function set dataIndex(value:int):void
		{
			_dataIndex=value;
		}

		[Bindable("dataChange")]
		public function get data():Object
		{
			return _data;
		}

		public function get listData():BaseListData
		{
			return _listData;
		}

		public function set listData(value:BaseListData):void
		{
			_listData=DataGridListData(value);
		}

		public function set data(value:Object):void
		{
			_data=value;
			this.dataIndex=(listData.owner).dataProvider.getItemIndex(data);
			this.invalidateProperties();
			dispatchEvent(new FlexEvent("dataChange"));
		}

		override protected function createChildren():void
		{
			super.createChildren();
		}

		override protected function commitProperties():void
		{
			super.commitProperties();
			updateRenderer();
		}

		override protected function measure():void
		{
			super.measure();
//			this.measuredHeight=22;
		}

		protected function updateRenderer():void
		{
		}

		public function get text():Object
		{
			return "";
		}

		public function getFocusable():UIComponent
		{
			return null;
		}

		/**
		 * initialize a new instance
		 */
		public function newInstance():*
		{
			return new BaseRenderer();
		}
	}
}