?
Solved

overriding background color - color lost on mouse roll-over

Posted on 2011-10-27
6
Medium Priority
?
342 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:royjayd
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 37042916
Can you provide a full code.

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

Author Comment

by:royjayd
ID: 37043016
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
 

Author Comment

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

thanks
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:royjayd
ID: 37044170
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
 
LVL 29

Accepted Solution

by:
dgofman earned 2000 total points
ID: 37054940
You need to get datagrid dataPRovider and update data bny setting a new value
0

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question