Flex grid 复杂表头

阅读更多

Flex grid 复杂表头

第一种 最简单的两重表头

code 如下:

 



	
	
		
	
	
	
		
		        
			
				
					
						
							
							
						
					
				
			        
			
			
				
				
				
					
					
				
				
					
					
				
				
			
		
	
	

 

第二种 复杂表头

定制ClassFactory。。。重写展现方式

Flex grid 复杂表头_第1张图片

Code

 



	
	
		
	
	
	
		
		        
			
				
					
						
							
							
						
					
				
			        
			
			
				
				
				
					
					
				
				
					
					
				
				
			
		
	
	

classfactory 如下:

HeaderRenderer

 



	
		
	
	
	
		
	
	
		
			
			
		
		
			
			
		
		
			
			
			
		
	
 
  

 

TestGridHeader

 

package 
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import mx.containers.VBox;
	import mx.controls.Alert;
	import mx.controls.ToolTip;
	import mx.controls.listClasses.IListItemRenderer;
	import mx.core.FlexGlobals;
	import mx.messaging.AbstractConsumer;

	public class TestGridHeader extends VBox implements IListItemRenderer {
		[Bindable]public var fullName:String;
		[Bindable]public var shortName:String;
		[Bindable]public var mouseOverTitle:String;
		[Bindable]public var hasAccess:Boolean = true;
		[Bindable]public var wrapText:Boolean = false;
		private var _lbl:TextField;
		
		override protected function createChildren():void {
			super.createChildren();
			var _txtFormat:TextFormat = new TextFormat();
			_txtFormat.font = "myPlainFont";
			_txtFormat.size = 11;
			_txtFormat.bold = true;
			_txtFormat.color = 0x020264;
			_txtFormat.align = "left";
			
			_lbl = new TextField();
			_lbl.alpha = 1
			_lbl.wordWrap = wrapText;
			_lbl.autoSize = TextFieldAutoSize.LEFT;
			_lbl.embedFonts = true;
			_lbl.antiAliasType = AntiAliasType.ADVANCED;
			_lbl.defaultTextFormat = _txtFormat;
			_lbl.rotation = 270;
			_lbl.mouseEnabled = false;
			_lbl.width = 60;
			_lbl.height = 100;
			
			var sprite:Sprite = new Sprite();
			sprite.buttonMode = true;//Mouse Hand Cursor
			sprite.addChild(_lbl);
			
			rawChildren.addChild(sprite);
			this.toolTip = mouseOverTitle;
		}
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			if(shortName != null && shortName != "") {
				_lbl.textColor = 0xffffff;
				_lbl.text = shortName;
				_lbl.y = 25;
				_lbl.x = (width - _lbl.width)/2;
				_lbl.textColor = 0x020264;
			}
		}
	}
}



 

 

你可能感兴趣的:(flex)