Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Report Scripting : change cell background
Report Scripting : change cell background [message #144596] Thu, 16 March 2006 17:16 Go to next message
Dov Moryusef is currently offline Dov MoryusefFriend
Messages: 25
Registered: July 2009
Junior Member
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
Re: Report Scripting : change cell background [message #144663 is a reply to message #144596] Thu, 16 March 2006 18:39 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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
Re: Report Scripting : change cell background [message #145006 is a reply to message #144663] Fri, 17 March 2006 10:48 Go to previous message
Dov Moryusef is currently offline Dov MoryusefFriend
Messages: 25
Registered: July 2009
Junior Member
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
>
>
>
Previous Topic:Images in a xml datasource
Next Topic:java.lang.OutOfMemoryError: PermGen
Goto Forum:
  


Current Time: Mon Jul 22 05:38:13 GMT 2024

Powered by FUDForum. Page generated in 0.03336 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top