Flex DataGrid 动态改变headerRender 属性&itemRender 改变单元格颜色

很多时候会用到动态改变datagrid的headerRender 或者itemRender的属性值,也会有设置单元格的颜色的要求。



	
		
			
				Christina Coenraets
				555-219-2270
				[email protected]
				true
				101
			
			
				Joanne Wall
				555-219-2012
				[email protected]
				true
				80
			
			
				Maurice Smith
				555-219-2012
				[email protected]
				false
				-110
			
			
				Mary Jones
				555-219-2000
				[email protected]
				true
				0
			
		
	
	
		
	
	
		
	
	
	
	
		
			
			
				
					
					
						
							
								
							
						
					
				
			
			
		
	

 CustomHeadRender.as

package com.render
{
	import mx.controls.dataGridClasses.DataGridItemRenderer;
	/*这个是外部render*/
	public class CustomHeadRender extends DataGridItemRenderer
	{
		private var _baseValue:int;
		public function set baseValue(value:int):void
		{
			_baseValue = value;
		}
		
		public function get baseValue():int
		{
			return this._baseValue;
		}
		
		override public function validateProperties():void
		{
			super.validateProperties();
			if(baseValue == 1)
			{
				this.text = "CustomHeader1";
			}
			else
			{
				this.text = "DefaultHeader1";
			}
		}
		
	}
}

 CustomItemRender.mxml



	
		 100)
					{
						color = 0xff0000;
					}
					else if(Number(listData.label) > 0)
					{
						color = 0x00ff00;
					}
					else
					{
						color = 0xffffff;
					}
					autoDrawBackGroup = color != 0xffffff;
				}
			}
		]]>
	
	

 

你可能感兴趣的:(Flex)