overriding background color - color lost on mouse roll-over

hi guys

this is my code

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			var g:Graphics = graphics;
			g.clear();
			var color : Object ;
			color = getStyle("backgroundColor");
			
			if(listData != null){
			var grid1:SaveDataGrid = DataGrid(DataGridListData(listData).owner);
			if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data))
			return; 
			var  smTolm:String = new String();
			smTolm = String(data[DataGridListData(listData).dataField]);
			var pair:Array = smTolm.split("|");
			
			if(pair.length == 2){
							
				if(pair[0] == "CEO "){
					
					if(Number(pair[1]) > 0){ 
						g.beginFill(0xff0000);
						g.drawRect(0, 0, unscaledWidth, unscaledHeight); g.endFill();
						g.endFill();							
						data[DataGridListData(listData).dataField] = pair[1];  //This is not working. any idea why
					}

Open in new window

Two questions i have is

1. When i roll over the row i loose the color effect.

2.on the grid i want to replace the current data with pair[1] , so i am doing
data[DataGridListData(listData).dataField] = pair[1]; but  its not working
, any idea how i can make it work?

thanks
royjaydAsked:
Who is Participating?
 
dgofmanCommented:
You need to get datagrid dataPRovider and update data bny setting a new value
0
 
dgofmanCommented:
Can you provide a full code.

1. When i roll over the row i loose the color effect. ???
0
 
royjaydAuthor Commented:
this the full code...
creating renderer like this


[Style(name="rowBackground", type="uint", format="Color", inherit="no")]
public class MatrixcolorRenderer extends Label { 	 
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			var g:Graphics = graphics;
			g.clear();
			var color : Object ;
			color = getStyle("backgroundColor");
			
			if(listData != null){
			var grid1:SaveDataGrid = DataGrid(DataGridListData(listData).owner);
			if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data))
			return; 
			var  smTolm:String = new String();
			smTolm = String(data[DataGridListData(listData).dataField]);
			var pair:Array = smTolm.split("|");
			
			if(pair.length == 2){
							
				if(pair[0] == "CEO "){
					
					if(Number(pair[1]) > 0){ 
						g.beginFill(0xff0000);
						g.drawRect(0, 0, unscaledWidth, unscaledHeight); g.endFill();
						g.endFill();							
						data[DataGridListData(listData).dataField] = pair[1];  //This is not working. any idea why
					} 

Toggle HighlightingOpen in New WindowSelect All

Open in new window


and calling the  MatrixcolorRenderer from my customgrid.as
public class Customgrid extends VBox 
	{
		private function buildColumnModel(complexheaders:Object,fields:Object):void{
			var headerCollection:Array = complexheaders as Array;
			fieldCollection = new ArrayCollection();
			var columnIndex:int = 0;
			var columnArray:Array = new Array(); 
			var column:AdvancedDataGridColumn;
			var index:int = 0;
			for(var i:String in fields){
				fieldCollection.addItemAt(fields[i],index)
				index++;
			}
			for(var j:int=0;j<complexHeaderCollection.length;j++){
				var complexHeader:Object  = complexHeaderCollection[j];
				var fieldObject:Object = fieldCollection.getItemAt(columnIndex) as Object;				 
					var Singlecolumn:AdvancedDataGridColumn = new AdvancedDataGridColumn();
					Singlecolumn =  createColumn(columnIndex,fieldObject);
					columnIndex++;
					columnArray.push(Singlecolumn);
				 
			}
			dataGrid.groupedColumns= columnArray;
			 
		}
		
		private function createColumn(columnIndex:int,fieldObject:Object):AdvancedDataGridColumn{
			var column:AdvancedDataGridColumn = new AdvancedDataGridColumn();
			column.headerText = fieldObject.defCaption;
			column.dataField = "col"+columnIndex;
			var factory:ClassFactory;
			var textAlign:String ="left";
			column.editable = false;
			column.showDataTips = true;
			if(fieldObject.hasOwnProperty("textAlign")){
				textAlign = fieldObject.textAlign;	
			}
			column.setStyle("textAlign",textAlign);
			 
			
			if(fieldObject.hasOwnProperty("resizable")){
				column.resizable = fieldObject.resizable;	
			}
			if (fieldObject.hasOwnProperty("display")) {
				column.visible = fieldObject.display;		
			}
			if(fieldObject.hasOwnProperty("cellEditable") && fieldObject["cellEditable"] == "true"){
				column.editable = true;
				cmtryCol = column.dataField;
				//applying header color
				var dgHeaderStyles:CSSStyleDeclaration = new CSSStyleDeclaration(".myHeaderStyles");
				dgHeaderStyles.setStyle("color","#078df0");
				column.setStyle("headerStyleName", "myHeaderStyles");
			}
			if(columnIndex == 5 || columnIndex == 6 || columnIndex == 7 || columnIndex == 8){  
				column.itemRenderer  = new ClassFactory(MatrixcolorRenderer);  // My Renderer
			}
			//For Number formatting
			if(fieldObject.hasOwnProperty("format") && fieldObject["format"] == "number"){
				column.labelFunction = formatData;
			}
			if (fieldObject.hasOwnProperty("width")) {
				column.width = fieldObject["width"];	
			}
			if (fieldObject.hasOwnProperty("sortable")) {
				column.sortable = fieldObject["sortable"];	
			}
			return column;
		}
}

Open in new window

0
KuppingerCole Reviews AlgoSec in Executive Report

Leading analyst firm, KuppingerCole reviews AlgoSec's Security Policy Management Solution, and the security challenges faced by companies today in their Executive View report.

 
royjaydAuthor Commented:
also i am trying to set
data[DataGridListData(listData).dataField] = pair[1];
but  its not working.

thanks
0
 
royjaydAuthor Commented:
actually the color effect problem is resolved now. the only problem is
i am trying to set the data to listData by
data[DataGridListData(listData).dataField] = pair[1];

but the datagrid is not getting updated
0
 
royjaydAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.