| 
 | 
| Re: Report Scripting : change cell background [message #145006 is a reply to message #144663] | 
Fri, 17 March 2006 05:48   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I've found the solution .... 
I've created a class which implements ICellEventHandler and applied it  
to the specific cell in my rptdesign : 
 
For example : 
 
public class CellImpl implements ICellEventHandler { 
		 
public void onCreate(ICellInstance arg0, IReportContext arg1) { 
	try { 
		Object data = arg0.getData(); 
		if (data != null) { 
			if ("".equals(data.toString().trim())) { 
			arg0.getStyle().setBackgroundColor("yellow"); 
			} 
		}				 
	} catch (Exception e) { 
		// TODO: handle exception 
	} 
} 
 
public void onPrepare(ICell arg0, IReportContext arg1) {} 
 
public void onRender(ICellInstance arg0, IReportContext arg1) {} 
 
} 
 
 
 
Best regards 
 
Dov 
 
Jason Weathersby a écrit : 
> You can set the background of a cell using the onCreate and 
> this.getStyle().backgroundColor = "blue"; 
>  
> I assume you want to do this based on a value in the control on the cell. 
>  
> If you have a value in a data element called samplevalue  in the cell and  
> you color the cell if this value is > 5, 
> then in the onCreate of the row you could. 
>  
> if( this.getRowData().getExpressionValue( "row[SampleValue]" ) > 5 ){ 
>   yellowme = true; 
> }else{ 
>  yellowme = false; 
> } 
>  
> define yellowme in initialize 
>  
> yellowme = false; 
>  
> finally on the chosen cell 
>  
> if( yellowme ){ 
>    this.getStyle().backgroundColor = "Yellow"; 
> } 
>  
> I dont think this will work if you try to to set it on the getValue() of the  
> control, because by that time the onCreate has already been executed on the 
> cell. 
>  
> Jason 
>  
>  
> "Dov MORYUSF" <moryusef@hotmail.com> wrote in message  
> news:dvc6nk$kh8$1@utils.eclipse.org... 
>  
>>Hi to all, 
>> 
>>Is it possible to change in a row the background of a unique cell ? 
>> 
>>I've found examples for changing the background of a whole row but not for  
>>a cell: 
>> http://www.eclipse.org/birt/phoenix/deploy/reportScripting.p hp 
>> 
>>Thanks a lot for your help 
>> 
>>DM  
>  
>  
>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.04704 seconds